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:
| Binary | Purpose |
|---|---|
apisorcery | Standard CLI (unchanged) |
apisorcery-mcp | MCP server (stdio transport) |
The MCP server exposes three tools:
| Tool | Description |
|---|---|
generate | Generate typed API client code from Swagger/OpenAPI specs. Reads .apisorceryrc.json from the current working directory. |
init | Create .apisorceryrc.json in the current working directory. |
register | Register the current machine as a device under an ApiSorcery account. |
Setup
1. Install Globally
npm i @apisorcery/cli -g2. Configure Your AI Assistant
Select the tab for your AI coding assistant:
// Global: ~/.claude/mcp.json
// Project: .mcp.json (in project root, share via git)
{
"mcpServers": {
"apisorcery": {
"command": "apisorcery-mcp"
}
}
}// Global: ~/.cursor/mcp.json
// Project: .cursor/mcp.json
{
"mcpServers": {
"apisorcery": {
"command": "apisorcery-mcp"
}
}
}{
"mcpServers": {
"apisorcery": {
"command": "apisorcery-mcp"
}
}
}// 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:
{
"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
abc123and remarksMacBook" → callsregister
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:
{
"mcpServers": {
"apisorcery": {
"command": "npx",
"args": ["-y", "@apisorcery/cli/mcp"]
}
}
}