Skip to content

MCP Integration

ApiSorcery ships a built-in MCP (Model Context Protocol) server so that AI coding assistants can call generate, init, and register directly — no manual CLI commands required.

How It Works

After global installation, two binaries are available:

BinaryPurpose
apisorceryStandard CLI (unchanged)
apisorcery-mcpMCP server (stdio transport)

The MCP server exposes three tools:

ToolDescription
generateGenerate typed API client code from Swagger/OpenAPI specs. Reads .apisorceryrc.json from the current working directory.
initCreate .apisorceryrc.json in the current working directory.
registerRegister the current machine as a device under an ApiSorcery account.

Setup

1. Install Globally

shell
npm i @apisorcery/cli -g

2. Configure Your AI Assistant

Select the tab for your AI coding assistant:

json
// Global: ~/.claude/mcp.json
// Project: .mcp.json (in project root, share via git)
{
  "mcpServers": {
    "apisorcery": {
      "command": "apisorcery-mcp"
    }
  }
}
json
// Global: ~/.cursor/mcp.json
// Project: .cursor/mcp.json
{
  "mcpServers": {
    "apisorcery": {
      "command": "apisorcery-mcp"
    }
  }
}
json
{
  "mcpServers": {
    "apisorcery": {
      "command": "apisorcery-mcp"
    }
  }
}
json
// Via a VS Code MCP extension such as Cline or Continue
// Open extension settings → MCP Servers → Edit config
{
  "mcpServers": {
    "apisorcery": {
      "command": "apisorcery-mcp"
    }
  }
}

Claude Code reads .mcp.json from the project root automatically — no restart needed after adding the file.
Cursor and Windsurf require restarting the application after editing the config file.

Working Directory

The MCP server inherits the working directory of the process that launched it. Make sure it points to your project root where .apisorceryrc.json lives. If needed, add a cwd field:

json
{
  "mcpServers": {
    "apisorcery": {
      "command": "apisorcery-mcp",
      "cwd": "/path/to/your/project"
    }
  }
}

3. Verify the Server Is Running

After configuration, ask your AI assistant to list available tools — it should show generate, init, and register.

Usage Examples

Once configured, you can ask your AI assistant:

  • "Initialize ApiSorcery for a Vue 3 TypeScript project" → calls init
  • "Generate the API client" → calls generate
  • "Register my device with token abc123 and remarks MacBook" → calls register

All log output from the server is written to stderr, keeping stdout clean for MCP JSON-RPC.

Without Global Install

If you prefer not to install globally, use npx in the config:

json
{
  "mcpServers": {
    "apisorcery": {
      "command": "npx",
      "args": ["-y", "@apisorcery/cli/mcp"]
    }
  }
}