# analyse_openapi

> Analyse an OpenAPI 3.x / Swagger 2.0 spec (JSON string) and preview what a WorkLens import would produce: object entities with field counts and ref lists,…

Section: MCP · Type: tool · Last updated: 2026-09-13

Analyse an OpenAPI 3.x / Swagger 2.0 spec (JSON string) and preview what a WorkLens import would produce: object entities with field counts and ref lists, inlined value-types, and cross-entity foreign keys. Use before recommending an import. Standalone entities are marked defaultSelected:false so a checklist can offer them as opt-ins. Convert YAML to JSON first.

## The picture

Agent (calls) → analyse_openapi (Draft a recipe) → Result (as data)

## Inputs

- spec_json (string, required) — The OpenAPI spec as a JSON string (≤ 5 MB). YAML specs must be JSON-converted first.

## When to call it

A preview, not an import. It tells you which schemas would become entities, which get inlined as value types, and how they connect.

defaultSelected: false marks standalone schemas - nothing references them and they reference nothing - so a checklist UI or an agent prompt can offer them as opt-ins rather than importing noise.

The spec must be JSON (5 MB max). Convert YAML first.

## Example request

```json
{
  "_comment": "Two schemas and one reference.",
  "name": "analyse_openapi",
  "arguments": {
    "spec_json": {
      "openapi": "3.0.0",
      "info": {
        "title": "shop",
        "version": "1"
      },
      "paths": {},
      "components": {
        "schemas": {
          "Customer": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "Order": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "customer": {
                "$ref": "#/components/schemas/Customer"
              },
              "total": {
                "type": "number"
              }
            }
          }
        }
      }
    }
  }
}
```

A string argument that holds JSON is shown unescaped here; send it as a string.

## Example response

```json
{
  "contract_version": 3,
  "entities": [
    {
      "name": "Customer",
      "fieldCount": 2,
      "referencesOut": [],
      "referencedBy": [
        "Order"
      ],
      "standalone": false,
      "defaultSelected": true
    },
    {
      "name": "Order",
      "fieldCount": 3,
      "referencesOut": [
        "Customer"
      ],
      "referencedBy": [],
      "standalone": false,
      "defaultSelected": true
    }
  ],
  "inlinedTypes": [],
  "relationships": [
    {
      "from": "Order",
      "fromField": "customer",
      "to": "Customer",
      "cardinality": "one"
    }
  ],
  "warnings": []
}
```

## Same step

- [get_recipe_schema](https://theworklens.com/docs/mcp/tools/get-recipe-schema): The recipe (GraphModel) authoring guide: JSON shape, every engine field type, FK conventions, rules and a working example. Call this FIRST, WITH A plan of what you are about to build (output csv or fixed, the constructs you expect, region, whether you are reading a repository): the reply then carries exactly what…
- [derive_graph](https://theworklens.com/docs/mcp/tools/derive-graph): Infer a data-free recipe (entity types, relationships) from a real sample file. Pass the file as base64. Use before generating relationship-preserving synthetic data.
- [Tool directory](https://theworklens.com/docs/mcp/tools): All 13 tools, grouped by step.

## Related

- [Tool directory](https://theworklens.com/docs/mcp/tools): All 13 tools the WorkLens MCP server exposes, grouped by the step they belong to, generated from the published contracts.
- [get_recipe_schema](https://theworklens.com/docs/mcp/tools/get-recipe-schema): The recipe (GraphModel) authoring guide: JSON shape, every engine field type, FK conventions, rules and a working example. Call this FIRST, WITH A plan of…
- [derive_graph](https://theworklens.com/docs/mcp/tools/derive-graph): Infer a data-free recipe (entity types, relationships) from a real sample file. Pass the file as base64. Use before generating relationship-preserving…

_← Previous: [derive_graph](https://theworklens.com/docs/mcp/tools/derive-graph) · Next: [validate_recipe](https://theworklens.com/docs/mcp/tools/validate-recipe) →_

_README, input schema and the primary worked request and response for this tool, published with the server. Source: mcp-schemas/tools/03-analyse_openapi._

_Canonical: https://theworklens.com/docs/mcp/tools/analyse-openapi · This copy: https://theworklens.com/docs/mcp/tools/analyse-openapi.md_
