Skip to main content
Glama

ai-mcp-server

Languages: English | 繁體中文 | 简体中文

Local MCP bridge: register multiple (api_key, base_url) pairs once, and let your Agent automatically discover and route to any model with the right capability (chat, vision, reasoning, embedding, image_gen, tts, stt, rerank).

Three entry points:

  • ai-mcp — CLI (manage endpoints, query models, trigger probes, init wizard)

  • ai-mcp-server — MCP stdio server, launched by Claude Desktop / Cursor / Cline / Trae

  • ai-mcp ui — local Web management dashboard (FastAPI + Jinja2, bound to 127.0.0.1)

Install

uv tool install ai-mcp-server

Option 2: Homebrew

brew install brianMacao/tap/ai-mcp-server

Option 3: npm / npx

npx ai-mcp-server      # auto-installs uv + Python package

Option 4: pip

pip install ai-mcp-server

Related MCP server: A2A MCP Server

Quickstart

# Interactive first-run wizard
ai-mcp init

# Or step by step:
ai-mcp endpoint add --name openrouter --base-url https://openrouter.ai/api/v1 --key sk-...
ai-mcp endpoint probe openrouter
ai-mcp model list --capability vision

# Start the Web UI
ai-mcp ui
# → http://127.0.0.1:8765/

# Start the MCP server (for Claude Desktop, Cursor, etc.)
ai-mcp-server

MCP Tools

ai-mcp-server exposes 6 MCP tools:

  • usage_guide — dynamic inventory, capability distribution, and routing guidance.

  • list_models — filter models by capability, context length, endpoint, and probe state.

  • invoke_model — pass through chat / embedding / image_gen / tts / stt / rerank calls; TTS audio is returned as audio_base64 inside the JSON body.

  • model_performance — inspect recent per-model call counts, success rate, and latency.

  • refresh_endpoint — refresh model lists and enqueue asynchronous capability probes.

  • add_models — manually register models for endpoints without /v1/models, or let an Agent register user-confirmed model features.

Model Feature Registration

Capabilities use canonical names such as text_chat, vision, audio_tts, audio_stt, embedding, and rerank. Common aliases including tts, stt, and asr are accepted by manual registration flows and normalized internally.

Static recognition includes these known model ids:

  • seed-tts-2.0audio_tts

  • volc.seedasr.sauc.durationaudio_stt

Register model features from the CLI:

ai-mcp model add --endpoint volc seed-tts-2.0 --capability audio_tts
ai-mcp model add --endpoint volc volc.seedasr.sauc.duration --features asr=true
ai-mcp model add --endpoint volc custom-model --features text_chat=true,context_length=32000
ai-mcp model override volc custom-model --capability vision=false

Register features from the Web UI:

ai-mcp ui
# Open http://127.0.0.1:8765/
# Use Models -> manual add, or Overrides -> add/update feature override.

Register features from an MCP client / Agent:

  1. Call usage_guide.

  2. Use add_models with capabilities for true capability flags.

  3. Use feature_overrides for explicit boolean or context-length overrides.

Example MCP arguments:

{
  "endpoint": "volc",
  "model_ids": ["seed-tts-2.0"],
  "feature_overrides": {
    "audio_tts": true,
    "context_length": 32000
  }
}

Claude Desktop / Trae / Codex Configuration

ai-mcp init will auto-detect installed MCP clients and configure them.

Manual configuration

Claude Desktop (claude_desktop_config.json):

{
  "mcpServers": {
    "ai-mcp": {
      "command": "uv",
      "args": ["run", "--from", "ai-mcp-server", "ai-mcp-server"]
    }
  }
}

Trae / Trae CN (project root .mcp.json):

{
  "mcpServers": {
    "ai-mcp": {
      "command": "uv",
      "args": ["run", "--from", "ai-mcp-server", "ai-mcp-server"],
      "transport": "stdio"
    }
  }
}

Codex Desktop (~/.codex/config.toml):

[mcp_servers.ai-mcp]
command = "uv"
args = ["run", "--from", "ai-mcp-server", "ai-mcp-server"]

Environment Variables

Variable

Purpose

Default

AI_MCP_CONFIG_DIR

Override data/config directory

~/.ai-mcp-server

AI_MCP_DB_PATH

SQLite database path

$AI_MCP_CONFIG_DIR/db.sqlite3

AI_MCP_MASTER_KEY

Fernet master key for api_key encryption

auto-generated → system keyring

AI_MCP_UI_TOKEN

Access token for Web UI when exposed (--expose)

none

Development

# Clone and set up
git clone https://github.com/brianMacao/ai-mcp-server
cd ai-mcp-server
uv sync

# Run tests
uv run pytest -q

# Verify against real endpoint
cp .keys.example .keys   # edit with your keys
source .keys
export AI_MCP_CONFIG_DIR="$(pwd)/.data"
export AI_MCP_MASTER_KEY="$(cat .data/.master_key)"  # first run generates this
uv run ai-mcp endpoint add --name test --base-url "$EXAMPLE_URL" --key "$EXAMPLE_API_KEY"
uv run ai-mcp endpoint probe test --capability text_chat -y

License

MIT

Available Tools

6 tools
add_modelsA

Manually register models or user-confirmed model features.

Args: endpoint: endpoint name. model_ids: one or more model_id to register. context_length: optional context window in tokens. capabilities: optional capability tags to mark as supported (override source). Aliases tts/stt/asr are accepted. feature_overrides: optional key/value overrides. Keys may be capability tags or context_length; capability values must be booleans. Example: {"audio_tts": true, "context_length": 32000}.

ParametersJSON Schema
NameRequiredDescriptionDefault
endpointYes
model_idsYes
capabilitiesNo
context_lengthNo
feature_overridesNo

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A3.8/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden for behavioral disclosure. It describes parameters but does not mention side effects (e.g., idempotency, overwrite behavior), authentication requirements, or error handling. This leaves significant behavioral uncertainty.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise, uses a clear 'Args:' list structure, and every sentence adds value. There is no redundant or extraneous information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description covers all parameters thoroughly but misses behavioral context and usage guidelines. Given the presence of an output schema (which may explain return values), the lack of behavioral details reduces completeness for a registration tool with no annotations.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description compensates fully by explaining each parameter in detail, including accepted values, aliases for capabilities, and a comprehensive example for feature_overrides. This adds significant meaning beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Manually register models or user-confirmed model features', specifying the verb (register) and resource (models/features). It distinguishes from sibling tools like list_models and invoke_model, which serve different purposes.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description does not explicitly state when to use this tool versus alternatives, nor does it provide exclusion criteria or prerequisites. It implies registration context but lacks direct guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

invoke_modelA

Forward a request to the selected (endpoint, model).

Args: endpoint: endpoint name registered via the CLI. model: model_id as returned by list_models. operation: one of chat / embedding / image_gen / tts / stt / rerank. payload: upstream-compatible body (OpenAI shape for openai-compat endpoints). The model field is set automatically. The response is passed through verbatim; errors are returned inside error.

ParametersJSON Schema
NameRequiredDescriptionDefault
modelYes
payloadYes
endpointYes
operationYes

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A4.1/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden. It discloses key behaviors: the `model` field is set automatically, response is passed through verbatim, errors are returned inside `error`. However, it does not mention side effects, idempotency, or rate limits, which would elevate transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is short (two sentences plus a bullet-like list of args) with no wasted words. It front-loads the purpose and efficiently conveys essential details about parameters and behavior.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (4 required params, nested objects, output schema present), the description covers purpose, all parameter semantics, and response behavior ('passed through verbatim'). The presence of an output schema reduces the need to describe return values; the description is sufficient for an agent to invoke the tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, so the description must add meaning. It explains each parameter: 'endpoint' is registered via CLI, 'model' from `list_models`, 'operation' enum values (chat, embedding, etc.), and 'payload' is upstream-compatible body with OpenAI shape. This greatly exceeds schema information.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's function: 'Forward a request to the selected (endpoint, model).' It uses a specific verb ('Forward') and resource ('request'), and distinguishes from siblings like 'list_models' by detailing operation types and payload handling.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context (requires endpoint and model, operation type) but does not explicitly state when to use this tool versus alternatives like 'model_performance' or 'add_models'. No when-not-to-use guidance is provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_modelsA

List models matching the filters.

Args: capability: capability tags the model must support (e.g. ["vision"]). min_context_length: minimum context window in tokens. endpoint: limit to a single endpoint name. include_unprobed: include models whose capabilities have not been probed yet (default True).

ParametersJSON Schema
NameRequiredDescriptionDefault
endpointNo
capabilityNo
include_unprobedNo
min_context_lengthNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are present, so the description carries the full burden. It discloses default behavior (include_unprobed=True) and parameter constraints but omits details like read-only nature, pagination, or potential costs. For a simple list tool, this is adequate but not thorough.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise with a front-loaded purpose sentence and organized Args list. Every sentence adds value, though minor improvements like separating purpose from args could enhance structure.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (4 optional params, output schema exists), the description covers purpose and all parameters. It doesn't discuss sorting or rate limits, but these are non-essential for a basic list operation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema coverage, the description fully compensates by explaining each parameter's purpose and format (e.g., capability as list of tags, min_context_length in tokens). This adds meaning beyond the schema's type and default values.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'List models matching the filters' with a specific verb ('list') and resource ('models'). It distinguishes itself from sibling tools like add_models (write) and invoke_model (invocation) as a read-only listing operation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage through filter parameters but does not explicitly specify when to use this tool instead of siblings like model_performance or usage_guide. No when-not or alternative guidance is provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

model_performanceB

Return近3天 aggregated call metrics per model (background-updated).

Args: endpoint: limit to a single endpoint name. sort_by: one of call_count / success_count / avg_first_byte_ms / avg_prompt_tokens / avg_output_tokens. limit: max rows to return.

Each row includes call_count, success_count, success_rate, avg_first_byte_ms, avg_prompt_tokens, avg_output_tokens, window_days.

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNo
sort_byNocall_count
endpointNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full burden. It mentions 'background-updated' indicating data is not real-time, which is a key behavioral trait. However, it omits details about data freshness, update frequency, permission requirements, or any side effects. More behavioral context needed for safe usage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Description is concise, starting with the main purpose in one sentence, then listing parameters in a clear Args format. No superfluous text. Well-structured for quick scanning.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With 3 optional parameters, output schema present, and no annotations, the description covers the essential behavior (3-day window, background update, parameter purposes). However, it does not mention default values or clarify whether the aggregation is per model or per endpoint (though 'per model' is stated). Adequate but leaves some gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Despite 0% schema description coverage, the description explains all three parameters (endpoint, sort_by, limit) with meanings and valid values. For sort_by, it lists the possible field names. This adds meaningful context beyond the schema's type information. Default values are only in schema, not description, but the explanation is sufficient.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states it returns aggregated call metrics per model for the last 3 days, with a note about background-updated data. It distinguishes from sibling list_models (list models) and invoke_model (invoke model). The Chinese phrase '近3天' may cause slight ambiguity but overall purpose is clear.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives like list_models or invoke_model. No explicit when-to-use or when-not-to-use criteria. The description only covers parameters, not usage context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

refresh_endpointA

Enqueue probe jobs. Server-internal worker will drain them.

Args: endpoint: endpoint name; if None, refresh every endpoint. capabilities: list of capability tags; if None, choose probes per model using known metadata. refresh_model_list: re-fetch /v1/models first (default True).

ParametersJSON Schema
NameRequiredDescriptionDefault
endpointNo
capabilitiesNo
refresh_model_listNo

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A4.2/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses the asynchronous nature by mentioning enqueuing and server-internal workers, but lacks details on authorization, side effects, or idempotency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise with a front-loaded purpose sentence and a structured Args section. Every sentence adds value without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (3 optional parameters) and the presence of an output schema, the description sufficiently covers functionality. It explains parameter defaults and the asynchronous mechanism.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description fully explains each parameter's behavior, including defaults and conditional logic (e.g., 'if None, refresh every endpoint'). This adds significant value beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool enqueues probe jobs to refresh endpoints, with a specific verb and resource. It distinguishes from sibling tools like add_models and invoke_model by focusing on endpoint refresh.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use this tool versus alternatives. The description implies usage when refresh is needed but does not provide when-not conditions or refer to sibling tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

usage_guideA

Return current capability inventory and usage instructions.

Call this first whenever you connect.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A4.4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must cover behavioral traits. It mentions returning information but does not explicitly state it is read-only or describe any side effects, rate limits, or permissions. Minimal but acceptable for a simple info tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two short sentences with no wasted words. The first sentence front-loads the purpose, and the second gives a clear usage directive.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (no parameters, output schema present), the description adequately explains what it returns and when to use it. It could elaborate slightly on the contents of the capability inventory, but the output schema likely fills that gap.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

There are zero parameters, so schema coverage is trivially 100%. The description adds no parameter info, but none is needed. Per rules, baseline for 0 params is 4.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool returns 'current capability inventory and usage instructions' and identifies it as the tool to call first. This distinguishes it from siblings like list_models or add_models, which are more specific.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly instructs 'Call this first whenever you connect', providing a clear usage directive. No alternatives are needed as it's a unique introductory tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 6 tool updatesv0.1.0
    • First observedadd_models
    • First observedinvoke_model
    • First observedlist_models
    • First observedmodel_performance
    • First observedrefresh_endpoint
    • First observedusage_guide

TDQS

A3.9/5.0

Scored across 6 tools

Disambiguation5/5

Each tool has a clear and distinct purpose: registration, inference, listing, metrics, probing, and guidance. No overlap in functionality.

Naming Consistency4/5

All tools use snake_case, but not all follow verb_noun pattern strictly (e.g., model_performance, usage_guide are noun_noun). Still clear and consistent in style.

Tool Count5/5

6 tools is well-scoped for an AI model server, covering registration, inference, listing, performance, probing, and guidance. Not too few or too many.

Completeness4/5

Covers core workflows (register, list, invoke, metrics, update via probe, guidance). Missing explicit delete or update tool for models, but add_models can override features, partially filling that gap.

Maintenance

ActivityStale
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers