MCP Spectral

by mark-sivill

324 downloads
Not rated
GitHub

About

MCP Spectral is a Model Context Protocol (MCP) server that uses Spectral to lint OpenAPI specifications. It is designed for developers who want to validate and fix OpenAPI documents through large language model (LLM) tools such as Claude Desktop.

Details

Author
mark-sivill
Downloads
324
Categories
Other, API

- Lints OpenAPI specifications using Spectral
- Lints OpenAPI specs with a custom Spectral ruleset
- Returns the installed Spectral version
- Runs inside a Docker container for easy setup
- Integrates with Claude Desktop via MCP

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name MCP Spectral
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Install Docker and Claude Desktop, then add a Docker run command for marksivill/mcp-spectral to the claude_desktop_config.json file. Restart Claude Desktop to access three tools: lint_openapi, lint_openapi_with_ruleset, and spectral_version. Use natural language prompts to lint or build OpenAPI specs.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "mcp spectral": {
            "OpenAPI linting (Spectral)": {
                "command": "docker",
                "args": [
                    "run",
                    "-i",
                    "--rm",
                    "marksivill/mcp-spectral"
                ]
            }
        }
    }
}

McpServers

{
    "OpenAPI linting (Spectral)": {
        "command": "docker",
        "args": [
            "run",
            "-i",
            "--rm",
            "marksivill/mcp-spectral"
        ]
    }
}

MCP Spectral Server

Model Context Protocol (MCP) Server for Spectral to lint OpenAPI specifications

Available tools

Tools provided by MCP Spectral

lint_openapi - lints OpenAPI specification
lint_openapi_with_ruleset - lints OpenAPI specification with Spectral ruleset
spectral_version - returns version of Spectral being used

Set up instructions

These instruction assume Anthropic Claude Desktop will interact with the MCP Spectral server. If another Large Language Model tool is being used change the set up instructions accordlingly.

Installation prerequisites

Ensure the following applications are installed on the local machine

Claude Desktop install
Docker install

Update Claude Desktop

Add following to the claude_desktop_config.json file within the Claude Desktop installation which tells Claude Desktop how to access MCP Spectral

{
  "mcpServers": {
    "OpenAPI linting (Spectral)": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "marksivill/mcp-spectral"
      ]
    }
  }
}

For example if MCP Spectral is also installed with mcp/fetch the complete claude_desktop_config.json would be

{
  "mcpServers": {
    "fetch": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "mcp/fetch"
      ]
    },
    "OpenAPI linting (Spectral)": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "marksivill/mcp-spectral"
      ]
    }
  }
}

Once the file has been updated, restart the Claude Desktop.

Claude Desktop will automatically pull the latest docker version of MCP Spectral from Docker Hub

Example Claude Desktop prompts

Below are example prompts for Claude Desktop which may also work in other Large Language Model (LLM) tools that are calling MCP Spectral.

Note mcp/fetch may also need to be installed into Claude Desktop to fetch URLs.

Prompt 1

What version of Spectral do we have access to

Prompt 2

Validate the OpenAPI specification from OpenWeatherMap API.
If any errors are found, fix them, then revalidate, repeat the last steps until the OpenAPI specification is valid.

Prompt 3

Using the API documentation found at https://wheretheiss.at/w/developer build an OpenAPI specification.
Ensure that there are no validation errors.
If any errors are found, fix them, then revalidate, repeat the last steps until the OpenAPI specification is valid.

Prompt 4

Build an OpenAPI specification version 3.1 for the Rick and Morty API.
Ensure that there are no validation errors.
If any errors are found, fix them, then revalidate, repeat the last steps until the OpenAPI specification is valid.

Prompt 5

Using the API documentation found at https://wheretheiss.at/w/developer build an OpenAPI specification version 3.1 using the rules
1) ensure all operationIds use kebab case
2) add info and contact information using your details
3) ensure servers are defined
4) ensure all operations contains a description
5) ensure all operations have one or more relevant tags
6) ensure there is a tag section

Ensure that there are no validation errors.
If any errors are found, fix them, then revalidate, repeat the last steps until the OpenAPI specification is valid.

Useful links

What is an MCP Server?⁠
MCP Spectral on Docker Hub
Spectral linter for OpenAPI specifications

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.