Skip to main content

MCP Server

@keq-request/cli includes a built-in Model Context Protocol (MCP) server that exposes your project's API directory as tools callable by AI assistants (Claude, Cursor, etc.).

Starting

keq mcp [options]
OptionDescription
-c --config <config_file_path>Path to the configuration file
--tolerantTolerant mode: ignores invalid Swagger/OpenAPI document structure
--debugPrint debug information

The MCP Server communicates via the stdio transport protocol, making it suitable for launching as a subprocess of an AI editor.

Configuring AI Editors

tip

It's recommended to configure the MCP Server in the project directory rather than globally, so each project can independently manage its own API context.

Claude Code

Add to .mcp.json in your project root:

{
  "mcpServers": {
    "keq": {
      "command": "npx",
      "args": ["@keq-request/cli", "mcp"]
    }
  }
}

Cursor

Add to .cursor/mcp.json in your project:

{
  "mcpServers": {
    "keq": {
      "command": "npx",
      "args": ["keq", "mcp"]
    }
  }
}

VS Code

Add to .vscode/mcp.json in your project:

{
  "servers": {
    "keq": {
      "command": "npx",
      "args": ["keq", "mcp"]
    }
  }
}

Available Tools

The MCP Server registers the following tools for AI assistants to call:

search_apis

Semantic search for API endpoints using natural language, supporting cross-language matching in Chinese and English.

ParameterTypeRequiredDescription
querystringYesNatural language search query
modulestring[]NoFilter by module name
limitnumberNoMaximum number of results (default: 10)

get_api_detail

Get the complete definition of a specified API, including request parameters, request body, and response body JSON Schema.

ParameterTypeRequiredDescription
modulestringYesModule name
methodstringYesHTTP method (GET, POST, PUT, DELETE, etc.)
pathnamestringYesAPI path (e.g., /api/v1/users)

list_modules

List all API modules configured in .keqrc.

No parameters required.

list_apis

List structured information for all API endpoints (module, method, path, operationId, summary).

ParameterTypeRequiredDescription
modulestring[]NoFilter by module name
methodstringNoFilter by HTTP method
pathnamestringNoFilter by path (supports glob wildcards)
includesstring[]NoContent to include, options: operations, components (default: ['operations'])

build_apis

Generate type-safe TypeScript client code for specified API endpoints. Files are written to the output directory configured in .keqrc.

ParameterTypeRequiredDescription
modulestring[]NoModules to generate code for
methodstringNoFilter by HTTP method
pathnamestringNoFilter by path (supports glob wildcards, e.g., /api/v1/users/**)
freshbooleanNoClear output directory before building (default: false)

list_generated_files

List generated TypeScript client files. Optionally list only invalid/outdated files.

ParameterTypeRequiredDescription
invalidbooleanNoWhen true, only lists outdated files not in current build output (default: false)

get_filter_rules

View the current .keqfilter file contents. Filter rules control which APIs generate code.

No parameters required.

add_filter_rule

Add a filter rule to .keqfilter. deny rules exclude APIs from code generation, allow rules include them.

ParameterTypeRequiredDescription
modestringYesRule mode: deny or allow
modulestringNoModule name pattern (supports glob, default: *)
methodstringNoHTTP method pattern (default: *)
pathnamestringYesPath pattern (supports glob)
buildbooleanNoWhether to automatically rebuild after adding the rule (default: false)

remove_filter_rule

Remove a specified filter rule from .keqfilter.

ParameterTypeRequiredDescription
modestringYesBlock the rule belongs to: deny or allow
modulestringYesExact match module name pattern
methodstringYesExact match method pattern
pathnamestringYesExact match path pattern
buildbooleanNoWhether to automatically rebuild after removing the rule (default: false)

Auto-Reload

The MCP Server monitors changes to .keqrc and .keqfilter files. When these files are modified, the server automatically recompiles the API index without requiring a manual restart.