ai-mcp-server 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +188 -0
- package/README.zh-CN.md +183 -0
- package/README.zh-TW.md +183 -0
- package/cli.js +61 -0
- package/package.json +30 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Brian
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# ai-mcp-server
|
|
2
|
+
|
|
3
|
+
**Languages:** English | [繁體中文](README.zh-TW.md) | [简体中文](README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
Local MCP bridge: register multiple (api_key, base_url) pairs once, and let your Agent
|
|
6
|
+
automatically discover and route to any model with the right capability (chat, vision,
|
|
7
|
+
reasoning, embedding, image_gen, tts, stt, rerank).
|
|
8
|
+
|
|
9
|
+
Three entry points:
|
|
10
|
+
- **`ai-mcp`** — CLI (manage endpoints, query models, trigger probes, init wizard)
|
|
11
|
+
- **`ai-mcp-server`** — MCP stdio server, launched by Claude Desktop / Cursor / Cline / Trae
|
|
12
|
+
- **`ai-mcp ui`** — local Web management dashboard (FastAPI + Jinja2, bound to 127.0.0.1)
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
### Option 1: uv (recommended)
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
uv tool install ai-mcp-server
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Option 2: Homebrew
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
brew install brianMacao/tap/ai-mcp-server
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Option 3: npm / npx
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npx ai-mcp-server # auto-installs uv + Python package
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Option 4: pip
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install ai-mcp-server
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Quickstart
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# Interactive first-run wizard
|
|
44
|
+
ai-mcp init
|
|
45
|
+
|
|
46
|
+
# Or step by step:
|
|
47
|
+
ai-mcp endpoint add --name openrouter --base-url https://openrouter.ai/api/v1 --key sk-...
|
|
48
|
+
ai-mcp endpoint probe openrouter
|
|
49
|
+
ai-mcp model list --capability vision
|
|
50
|
+
|
|
51
|
+
# Start the Web UI
|
|
52
|
+
ai-mcp ui
|
|
53
|
+
# → http://127.0.0.1:8765/
|
|
54
|
+
|
|
55
|
+
# Start the MCP server (for Claude Desktop, Cursor, etc.)
|
|
56
|
+
ai-mcp-server
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## MCP Tools
|
|
60
|
+
|
|
61
|
+
`ai-mcp-server` exposes 6 MCP tools:
|
|
62
|
+
|
|
63
|
+
- `usage_guide` — dynamic inventory, capability distribution, and routing guidance.
|
|
64
|
+
- `list_models` — filter models by capability, context length, endpoint, and probe state.
|
|
65
|
+
- `invoke_model` — pass through chat / embedding / image_gen / tts / stt / rerank calls;
|
|
66
|
+
TTS audio is returned as `audio_base64` inside the JSON body.
|
|
67
|
+
- `model_performance` — inspect recent per-model call counts, success rate, and latency.
|
|
68
|
+
- `refresh_endpoint` — refresh model lists and enqueue asynchronous capability probes.
|
|
69
|
+
- `add_models` — manually register models for endpoints without `/v1/models`, or let an
|
|
70
|
+
Agent register user-confirmed model features.
|
|
71
|
+
|
|
72
|
+
## Model Feature Registration
|
|
73
|
+
|
|
74
|
+
Capabilities use canonical names such as `text_chat`, `vision`, `audio_tts`,
|
|
75
|
+
`audio_stt`, `embedding`, and `rerank`. Common aliases including `tts`, `stt`,
|
|
76
|
+
and `asr` are accepted by manual registration flows and normalized internally.
|
|
77
|
+
|
|
78
|
+
Static recognition includes these known model ids:
|
|
79
|
+
|
|
80
|
+
- `seed-tts-2.0` → `audio_tts`
|
|
81
|
+
- `volc.seedasr.sauc.duration` → `audio_stt`
|
|
82
|
+
|
|
83
|
+
Register model features from the CLI:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
ai-mcp model add --endpoint volc seed-tts-2.0 --capability audio_tts
|
|
87
|
+
ai-mcp model add --endpoint volc volc.seedasr.sauc.duration --features asr=true
|
|
88
|
+
ai-mcp model add --endpoint volc custom-model --features text_chat=true,context_length=32000
|
|
89
|
+
ai-mcp model override volc custom-model --capability vision=false
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Register features from the Web UI:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
ai-mcp ui
|
|
96
|
+
# Open http://127.0.0.1:8765/
|
|
97
|
+
# Use Models -> manual add, or Overrides -> add/update feature override.
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Register features from an MCP client / Agent:
|
|
101
|
+
|
|
102
|
+
1. Call `usage_guide`.
|
|
103
|
+
2. Use `add_models` with `capabilities` for true capability flags.
|
|
104
|
+
3. Use `feature_overrides` for explicit boolean or context-length overrides.
|
|
105
|
+
|
|
106
|
+
Example MCP arguments:
|
|
107
|
+
|
|
108
|
+
```json
|
|
109
|
+
{
|
|
110
|
+
"endpoint": "volc",
|
|
111
|
+
"model_ids": ["seed-tts-2.0"],
|
|
112
|
+
"feature_overrides": {
|
|
113
|
+
"audio_tts": true,
|
|
114
|
+
"context_length": 32000
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Claude Desktop / Trae / Codex Configuration
|
|
120
|
+
|
|
121
|
+
`ai-mcp init` will auto-detect installed MCP clients and configure them.
|
|
122
|
+
|
|
123
|
+
### Manual configuration
|
|
124
|
+
|
|
125
|
+
**Claude Desktop** (`claude_desktop_config.json`):
|
|
126
|
+
```json
|
|
127
|
+
{
|
|
128
|
+
"mcpServers": {
|
|
129
|
+
"ai-mcp": {
|
|
130
|
+
"command": "uv",
|
|
131
|
+
"args": ["run", "--from", "ai-mcp-server", "ai-mcp-server"]
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**Trae / Trae CN** (project root `.mcp.json`):
|
|
138
|
+
```json
|
|
139
|
+
{
|
|
140
|
+
"mcpServers": {
|
|
141
|
+
"ai-mcp": {
|
|
142
|
+
"command": "uv",
|
|
143
|
+
"args": ["run", "--from", "ai-mcp-server", "ai-mcp-server"],
|
|
144
|
+
"transport": "stdio"
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**Codex Desktop** (`~/.codex/config.toml`):
|
|
151
|
+
```toml
|
|
152
|
+
[mcp_servers.ai-mcp]
|
|
153
|
+
command = "uv"
|
|
154
|
+
args = ["run", "--from", "ai-mcp-server", "ai-mcp-server"]
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Environment Variables
|
|
158
|
+
|
|
159
|
+
| Variable | Purpose | Default |
|
|
160
|
+
|---|---|---|
|
|
161
|
+
| `AI_MCP_CONFIG_DIR` | Override data/config directory | `~/.ai-mcp-server` |
|
|
162
|
+
| `AI_MCP_DB_PATH` | SQLite database path | `$AI_MCP_CONFIG_DIR/db.sqlite3` |
|
|
163
|
+
| `AI_MCP_MASTER_KEY` | Fernet master key for api_key encryption | auto-generated → system keyring |
|
|
164
|
+
| `AI_MCP_UI_TOKEN` | Access token for Web UI when exposed (`--expose`) | none |
|
|
165
|
+
|
|
166
|
+
## Development
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
# Clone and set up
|
|
170
|
+
git clone https://github.com/brianMacao/ai-mcp-server
|
|
171
|
+
cd ai-mcp-server
|
|
172
|
+
uv sync
|
|
173
|
+
|
|
174
|
+
# Run tests
|
|
175
|
+
uv run pytest -q
|
|
176
|
+
|
|
177
|
+
# Verify against real endpoint
|
|
178
|
+
cp .keys.example .keys # edit with your keys
|
|
179
|
+
source .keys
|
|
180
|
+
export AI_MCP_CONFIG_DIR="$(pwd)/.data"
|
|
181
|
+
export AI_MCP_MASTER_KEY="$(cat .data/.master_key)" # first run generates this
|
|
182
|
+
uv run ai-mcp endpoint add --name test --base-url "$EXAMPLE_URL" --key "$EXAMPLE_API_KEY"
|
|
183
|
+
uv run ai-mcp endpoint probe test --capability text_chat -y
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## License
|
|
187
|
+
|
|
188
|
+
MIT
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# ai-mcp-server
|
|
2
|
+
|
|
3
|
+
**语言:** [English](README.md) | [繁體中文](README.zh-TW.md) | 简体中文
|
|
4
|
+
|
|
5
|
+
本地 MCP 桥梁:一次登记多组 `(api_key, base_url)`,让 Agent 可以按模型能力自动查询与调用合适的模型,例如 chat、vision、reasoning、embedding、image_gen、tts、stt、rerank。
|
|
6
|
+
|
|
7
|
+
三个入口:
|
|
8
|
+
|
|
9
|
+
- **`ai-mcp`**:CLI,用于管理 endpoint、查询模型、触发探活、初始化 MCP client 配置。
|
|
10
|
+
- **`ai-mcp-server`**:MCP stdio server,由 Claude Desktop、Cursor、Cline、Trae 等客户端拉起。
|
|
11
|
+
- **`ai-mcp ui`**:本地 Web 管理界面,FastAPI + Jinja2,默认绑定 `127.0.0.1`。
|
|
12
|
+
|
|
13
|
+
## 安装
|
|
14
|
+
|
|
15
|
+
### uv
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
uv tool install ai-mcp-server
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Homebrew
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
brew install brianMacao/tap/ai-mcp-server
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### npm / npx
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npx ai-mcp-server
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### pip
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install ai-mcp-server
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 快速开始
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# 交互式初始设置
|
|
43
|
+
ai-mcp init
|
|
44
|
+
|
|
45
|
+
# 或逐步设置:
|
|
46
|
+
ai-mcp endpoint add --name openrouter --base-url https://openrouter.ai/api/v1 --key sk-...
|
|
47
|
+
ai-mcp endpoint probe openrouter
|
|
48
|
+
ai-mcp model list --capability vision
|
|
49
|
+
|
|
50
|
+
# 启动 Web UI
|
|
51
|
+
ai-mcp ui
|
|
52
|
+
# → http://127.0.0.1:8765/
|
|
53
|
+
|
|
54
|
+
# 启动 MCP server
|
|
55
|
+
ai-mcp-server
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## MCP Tools
|
|
59
|
+
|
|
60
|
+
`ai-mcp-server` 暴露 6 个 MCP tool:
|
|
61
|
+
|
|
62
|
+
- `usage_guide`:动态 inventory、能力分布与推荐使用方式。
|
|
63
|
+
- `list_models`:按能力、context length、endpoint、探活状态筛选模型。
|
|
64
|
+
- `invoke_model`:透传 chat / embedding / image_gen / tts / stt / rerank 请求;TTS 音频会以 `audio_base64` 放在 JSON body 内返回。
|
|
65
|
+
- `model_performance`:查看近期每个模型的调用次数、成功率与延迟。
|
|
66
|
+
- `refresh_endpoint`:刷新模型列表并入队异步能力探活。
|
|
67
|
+
- `add_models`:为不提供 `/v1/models` 的 endpoint 手动登记模型,或让 Agent 登记用户已确认的模型特性。
|
|
68
|
+
|
|
69
|
+
## 模型特性登记
|
|
70
|
+
|
|
71
|
+
能力使用 canonical 名称,例如 `text_chat`、`vision`、`audio_tts`、`audio_stt`、`embedding`、`rerank`。手动登记流程也接受常用别名,例如 `tts`、`stt`、`asr`,并会在内部标准化。
|
|
72
|
+
|
|
73
|
+
目前静态识别包含:
|
|
74
|
+
|
|
75
|
+
- `seed-tts-2.0` → `audio_tts`
|
|
76
|
+
- `volc.seedasr.sauc.duration` → `audio_stt`
|
|
77
|
+
|
|
78
|
+
通过 CLI 登记模型特性:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
ai-mcp model add --endpoint volc seed-tts-2.0 --capability audio_tts
|
|
82
|
+
ai-mcp model add --endpoint volc volc.seedasr.sauc.duration --features asr=true
|
|
83
|
+
ai-mcp model add --endpoint volc custom-model --features text_chat=true,context_length=32000
|
|
84
|
+
ai-mcp model override volc custom-model --capability vision=false
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
通过 Web UI 登记:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
ai-mcp ui
|
|
91
|
+
# 打开 http://127.0.0.1:8765/
|
|
92
|
+
# 在 Models 手动新增,或到 Overrides 新增 / 更新特性覆盖。
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
通过 MCP client / Agent 登记:
|
|
96
|
+
|
|
97
|
+
1. 先调用 `usage_guide`。
|
|
98
|
+
2. 若要标记某些能力为 true,调用 `add_models` 并传入 `capabilities`。
|
|
99
|
+
3. 若要明确登记 true / false 或 context length,传入 `feature_overrides`。
|
|
100
|
+
|
|
101
|
+
MCP 参数示例:
|
|
102
|
+
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"endpoint": "volc",
|
|
106
|
+
"model_ids": ["seed-tts-2.0"],
|
|
107
|
+
"feature_overrides": {
|
|
108
|
+
"audio_tts": true,
|
|
109
|
+
"context_length": 32000
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Claude Desktop / Trae / Codex 配置
|
|
115
|
+
|
|
116
|
+
`ai-mcp init` 会尝试自动检测已安装的 MCP client 并写入配置。
|
|
117
|
+
|
|
118
|
+
手动配置示例:
|
|
119
|
+
|
|
120
|
+
**Claude Desktop** (`claude_desktop_config.json`):
|
|
121
|
+
|
|
122
|
+
```json
|
|
123
|
+
{
|
|
124
|
+
"mcpServers": {
|
|
125
|
+
"ai-mcp": {
|
|
126
|
+
"command": "uv",
|
|
127
|
+
"args": ["run", "--from", "ai-mcp-server", "ai-mcp-server"]
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**Trae / Trae CN**(项目根目录 `.mcp.json`):
|
|
134
|
+
|
|
135
|
+
```json
|
|
136
|
+
{
|
|
137
|
+
"mcpServers": {
|
|
138
|
+
"ai-mcp": {
|
|
139
|
+
"command": "uv",
|
|
140
|
+
"args": ["run", "--from", "ai-mcp-server", "ai-mcp-server"],
|
|
141
|
+
"transport": "stdio"
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**Codex Desktop** (`~/.codex/config.toml`):
|
|
148
|
+
|
|
149
|
+
```toml
|
|
150
|
+
[mcp_servers.ai-mcp]
|
|
151
|
+
command = "uv"
|
|
152
|
+
args = ["run", "--from", "ai-mcp-server", "ai-mcp-server"]
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## 环境变量
|
|
156
|
+
|
|
157
|
+
| 变量 | 用途 | 默认值 |
|
|
158
|
+
|---|---|---|
|
|
159
|
+
| `AI_MCP_CONFIG_DIR` | 覆盖数据 / 配置目录 | `~/.ai-mcp-server` |
|
|
160
|
+
| `AI_MCP_DB_PATH` | SQLite database 路径 | `$AI_MCP_CONFIG_DIR/db.sqlite3` |
|
|
161
|
+
| `AI_MCP_MASTER_KEY` | Fernet master key,用于加密 api_key | 自动生成并写入系统 keyring |
|
|
162
|
+
| `AI_MCP_UI_TOKEN` | Web UI 对外暴露时使用的 access token | 无 |
|
|
163
|
+
|
|
164
|
+
## 开发
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
git clone https://github.com/brianMacao/ai-mcp-server
|
|
168
|
+
cd ai-mcp-server
|
|
169
|
+
uv sync
|
|
170
|
+
|
|
171
|
+
uv run pytest -q
|
|
172
|
+
|
|
173
|
+
cp .keys.example .keys
|
|
174
|
+
source .keys
|
|
175
|
+
export AI_MCP_CONFIG_DIR="$(pwd)/.data"
|
|
176
|
+
export AI_MCP_MASTER_KEY="$(cat .data/.master_key)"
|
|
177
|
+
uv run ai-mcp endpoint add --name test --base-url "$EXAMPLE_URL" --key "$EXAMPLE_API_KEY"
|
|
178
|
+
uv run ai-mcp endpoint probe test --capability text_chat -y
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## License
|
|
182
|
+
|
|
183
|
+
MIT
|
package/README.zh-TW.md
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# ai-mcp-server
|
|
2
|
+
|
|
3
|
+
**語言:** [English](README.md) | 繁體中文 | [简体中文](README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
本地 MCP 橋樑:一次登記多組 `(api_key, base_url)`,讓 Agent 可以按模型能力自動查詢與調用合適的模型,例如 chat、vision、reasoning、embedding、image_gen、tts、stt、rerank。
|
|
6
|
+
|
|
7
|
+
三個入口:
|
|
8
|
+
|
|
9
|
+
- **`ai-mcp`**:CLI,用於管理 endpoint、查詢模型、觸發探活、初始化 MCP client 設定。
|
|
10
|
+
- **`ai-mcp-server`**:MCP stdio server,由 Claude Desktop、Cursor、Cline、Trae 等客戶端拉起。
|
|
11
|
+
- **`ai-mcp ui`**:本地 Web 管理介面,FastAPI + Jinja2,預設綁定 `127.0.0.1`。
|
|
12
|
+
|
|
13
|
+
## 安裝
|
|
14
|
+
|
|
15
|
+
### uv
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
uv tool install ai-mcp-server
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Homebrew
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
brew install brianMacao/tap/ai-mcp-server
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### npm / npx
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npx ai-mcp-server
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### pip
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install ai-mcp-server
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 快速開始
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# 互動式初始設定
|
|
43
|
+
ai-mcp init
|
|
44
|
+
|
|
45
|
+
# 或逐步設定:
|
|
46
|
+
ai-mcp endpoint add --name openrouter --base-url https://openrouter.ai/api/v1 --key sk-...
|
|
47
|
+
ai-mcp endpoint probe openrouter
|
|
48
|
+
ai-mcp model list --capability vision
|
|
49
|
+
|
|
50
|
+
# 啟動 Web UI
|
|
51
|
+
ai-mcp ui
|
|
52
|
+
# → http://127.0.0.1:8765/
|
|
53
|
+
|
|
54
|
+
# 啟動 MCP server
|
|
55
|
+
ai-mcp-server
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## MCP Tools
|
|
59
|
+
|
|
60
|
+
`ai-mcp-server` 暴露 6 個 MCP tool:
|
|
61
|
+
|
|
62
|
+
- `usage_guide`:動態 inventory、能力分佈與推薦使用方式。
|
|
63
|
+
- `list_models`:按能力、context length、endpoint、探活狀態篩選模型。
|
|
64
|
+
- `invoke_model`:透傳 chat / embedding / image_gen / tts / stt / rerank 請求;TTS 音訊會以 `audio_base64` 放在 JSON body 內返回。
|
|
65
|
+
- `model_performance`:查看近期每個模型的調用次數、成功率與延遲。
|
|
66
|
+
- `refresh_endpoint`:刷新模型列表並入隊異步能力探活。
|
|
67
|
+
- `add_models`:為不提供 `/v1/models` 的 endpoint 手動登記模型,或讓 Agent 登記使用者已確認的模型特性。
|
|
68
|
+
|
|
69
|
+
## 模型特性登記
|
|
70
|
+
|
|
71
|
+
能力使用 canonical 名稱,例如 `text_chat`、`vision`、`audio_tts`、`audio_stt`、`embedding`、`rerank`。手動登記流程也接受常用別名,例如 `tts`、`stt`、`asr`,並會在內部正規化。
|
|
72
|
+
|
|
73
|
+
目前靜態識別包含:
|
|
74
|
+
|
|
75
|
+
- `seed-tts-2.0` → `audio_tts`
|
|
76
|
+
- `volc.seedasr.sauc.duration` → `audio_stt`
|
|
77
|
+
|
|
78
|
+
透過 CLI 登記模型特性:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
ai-mcp model add --endpoint volc seed-tts-2.0 --capability audio_tts
|
|
82
|
+
ai-mcp model add --endpoint volc volc.seedasr.sauc.duration --features asr=true
|
|
83
|
+
ai-mcp model add --endpoint volc custom-model --features text_chat=true,context_length=32000
|
|
84
|
+
ai-mcp model override volc custom-model --capability vision=false
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
透過 Web UI 登記:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
ai-mcp ui
|
|
91
|
+
# 開啟 http://127.0.0.1:8765/
|
|
92
|
+
# 在 Models 手動新增,或到 Overrides 新增 / 更新特性覆寫。
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
透過 MCP client / Agent 登記:
|
|
96
|
+
|
|
97
|
+
1. 先調用 `usage_guide`。
|
|
98
|
+
2. 若要標記某些能力為 true,調用 `add_models` 並傳入 `capabilities`。
|
|
99
|
+
3. 若要明確登記 true / false 或 context length,傳入 `feature_overrides`。
|
|
100
|
+
|
|
101
|
+
MCP 參數範例:
|
|
102
|
+
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"endpoint": "volc",
|
|
106
|
+
"model_ids": ["seed-tts-2.0"],
|
|
107
|
+
"feature_overrides": {
|
|
108
|
+
"audio_tts": true,
|
|
109
|
+
"context_length": 32000
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Claude Desktop / Trae / Codex 設定
|
|
115
|
+
|
|
116
|
+
`ai-mcp init` 會嘗試自動偵測已安裝的 MCP client 並寫入設定。
|
|
117
|
+
|
|
118
|
+
手動設定範例:
|
|
119
|
+
|
|
120
|
+
**Claude Desktop** (`claude_desktop_config.json`):
|
|
121
|
+
|
|
122
|
+
```json
|
|
123
|
+
{
|
|
124
|
+
"mcpServers": {
|
|
125
|
+
"ai-mcp": {
|
|
126
|
+
"command": "uv",
|
|
127
|
+
"args": ["run", "--from", "ai-mcp-server", "ai-mcp-server"]
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**Trae / Trae CN**(專案根目錄 `.mcp.json`):
|
|
134
|
+
|
|
135
|
+
```json
|
|
136
|
+
{
|
|
137
|
+
"mcpServers": {
|
|
138
|
+
"ai-mcp": {
|
|
139
|
+
"command": "uv",
|
|
140
|
+
"args": ["run", "--from", "ai-mcp-server", "ai-mcp-server"],
|
|
141
|
+
"transport": "stdio"
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**Codex Desktop** (`~/.codex/config.toml`):
|
|
148
|
+
|
|
149
|
+
```toml
|
|
150
|
+
[mcp_servers.ai-mcp]
|
|
151
|
+
command = "uv"
|
|
152
|
+
args = ["run", "--from", "ai-mcp-server", "ai-mcp-server"]
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## 環境變數
|
|
156
|
+
|
|
157
|
+
| 變數 | 用途 | 預設值 |
|
|
158
|
+
|---|---|---|
|
|
159
|
+
| `AI_MCP_CONFIG_DIR` | 覆寫資料 / 設定目錄 | `~/.ai-mcp-server` |
|
|
160
|
+
| `AI_MCP_DB_PATH` | SQLite database 路徑 | `$AI_MCP_CONFIG_DIR/db.sqlite3` |
|
|
161
|
+
| `AI_MCP_MASTER_KEY` | Fernet master key,用於加密 api_key | 自動產生並寫入系統 keyring |
|
|
162
|
+
| `AI_MCP_UI_TOKEN` | Web UI 對外暴露時使用的 access token | 無 |
|
|
163
|
+
|
|
164
|
+
## 開發
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
git clone https://github.com/brianMacao/ai-mcp-server
|
|
168
|
+
cd ai-mcp-server
|
|
169
|
+
uv sync
|
|
170
|
+
|
|
171
|
+
uv run pytest -q
|
|
172
|
+
|
|
173
|
+
cp .keys.example .keys
|
|
174
|
+
source .keys
|
|
175
|
+
export AI_MCP_CONFIG_DIR="$(pwd)/.data"
|
|
176
|
+
export AI_MCP_MASTER_KEY="$(cat .data/.master_key)"
|
|
177
|
+
uv run ai-mcp endpoint add --name test --base-url "$EXAMPLE_URL" --key "$EXAMPLE_API_KEY"
|
|
178
|
+
uv run ai-mcp endpoint probe test --capability text_chat -y
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## License
|
|
182
|
+
|
|
183
|
+
MIT
|
package/cli.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawnSync, execSync } from "node:child_process";
|
|
3
|
+
import { basename } from "node:path";
|
|
4
|
+
import process from "node:process";
|
|
5
|
+
|
|
6
|
+
const BIN_NAME = basename(process.argv[1] || "ai-mcp");
|
|
7
|
+
const PKG = "ai-mcp-server";
|
|
8
|
+
|
|
9
|
+
function fail(msg) {
|
|
10
|
+
process.stderr.write(`\x1b[31m${PKG}\x1b[0m: ${msg}\n`);
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function info(msg) {
|
|
15
|
+
process.stderr.write(`\x1b[36m${PKG}\x1b[0m: ${msg}\n`);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function hasUv() {
|
|
19
|
+
try { execSync("uv --version", { stdio: "ignore" }); return true; }
|
|
20
|
+
catch { return false; }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function isInstalled() {
|
|
24
|
+
try {
|
|
25
|
+
const r = execSync("uv tool list --color never", { encoding: "utf-8" });
|
|
26
|
+
return r.includes(PKG);
|
|
27
|
+
} catch { return false; }
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// -- main --
|
|
31
|
+
if (!hasUv()) {
|
|
32
|
+
fail("uv is required. Install: https://docs.astral.sh/uv/getting-started/installation/");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (!isInstalled()) {
|
|
36
|
+
info(`uv tool install ${PKG} …`);
|
|
37
|
+
const r = spawnSync("uv", ["tool", "install", PKG], { stdio: "inherit" });
|
|
38
|
+
if (r.status !== 0) fail(`auto-install failed (exit ${r.status})`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const userArgs = process.argv.slice(2);
|
|
42
|
+
let entry, args;
|
|
43
|
+
|
|
44
|
+
switch (BIN_NAME) {
|
|
45
|
+
case "ai-mcp-ui":
|
|
46
|
+
entry = "ai-mcp";
|
|
47
|
+
args = ["ui", ...userArgs];
|
|
48
|
+
break;
|
|
49
|
+
case "ai-mcp-server":
|
|
50
|
+
entry = "ai-mcp-server";
|
|
51
|
+
args = userArgs;
|
|
52
|
+
break;
|
|
53
|
+
default: // "ai-mcp"
|
|
54
|
+
entry = "ai-mcp";
|
|
55
|
+
args = userArgs;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const result = spawnSync("uv", ["tool", "run", "--from", PKG, entry, "--", ...args], {
|
|
59
|
+
stdio: "inherit",
|
|
60
|
+
});
|
|
61
|
+
process.exit(result.status ?? 1);
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ai-mcp-server",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Local MCP bridge: unify multi-endpoint model capabilities into a single MCP server + CLI + Web UI",
|
|
5
|
+
"repository": "github:brianMacao/ai-mcp-server",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"bin": {
|
|
9
|
+
"ai-mcp": "./cli.js",
|
|
10
|
+
"ai-mcp-server": "./cli.js",
|
|
11
|
+
"ai-mcp-ui": "./cli.js"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {},
|
|
14
|
+
"files": [
|
|
15
|
+
"cli.js",
|
|
16
|
+
"package.json",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"keywords": [
|
|
20
|
+
"mcp",
|
|
21
|
+
"model-context-protocol",
|
|
22
|
+
"llm",
|
|
23
|
+
"ai",
|
|
24
|
+
"model-pool",
|
|
25
|
+
"openai-compatible"
|
|
26
|
+
],
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=18"
|
|
29
|
+
}
|
|
30
|
+
}
|