内容
<!-- aicom-mirror-notice -->
> **📖 只读镜像。** `aimarket-mcp` 从 AI-Factory monorepo 的规范仓库发布。
> **不接受拉取请求** — 任何提交到这里的内容都会被 `scripts/mirror_satellites.sh` 在下一次同步时覆盖。
> 🐞 发现了错误或有请求?请 **[打开问题](https://github.com/alexar76/aimarket-mcp/issues)**。
# aimarket-mcp — 生态系统 MCP 网关
<!-- mcp-name: io.github.alexar76/aimarket-mcp -->
<!-- aicom-readme-badges -->
<p align="center">
<a href="https://github.com/alexar76/aimarket-mcp/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/alexar76/aimarket-mcp/ci.yml?branch=main&label=CI" alt="CI" /></a>
<a href="https://glama.ai/mcp/servers/alexar76/aimarket-mcp"><img src="https://glama.ai/mcp/servers/alexar76/aimarket-mcp/badges/score.svg" alt="aimarket-mcp MCP server" /></a>
<img src="https://img.shields.io/badge/MCP-gateway-6e40c9" alt="MCP 网关" />
<img src="https://img.shields.io/badge/transport-stdio%20%2B%20HTTP-blue" alt="stdio + HTTP" />
<img src="https://img.shields.io/badge/tests-14_passing-brightgreen" alt="14 测试通过" />
<a href="docs/badges/coverage.svg"><img src="docs/badges/coverage.svg" alt="测试覆盖率" /></a>
<a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="许可证:MIT" /></a>
</p>
<!-- /aicom-readme-badges -->
**一个 MCP 网关。三个强化工具。由 Metis、ARGUS 和生态系统共享。**
传输:**stdio** (`mcp_stdio_server.py`) 用于 Glama / Claude Desktop / Cursor,基于官方 **Model Context Protocol** Python SDK (`mcp`,`FastMCP`)。
还附带 **Streamable-HTTP**,用于自托管部署 (`aimarket-mcp-http`,Docker Compose)。
| 项目 | 位置 |
|------|----------|
| MCP 入口点 (stdio) | [`mcp_stdio_server.py`](mcp_stdio_server.py) |
| MCP 网关 (HTTP) | [`aimarket_mcp/server.py`](aimarket_mcp/server.py) |
| 工具处理程序 + 安全 | [`aimarket_mcp/tools.py`](aimarket_mcp/tools.py),[`aimarket_mcp/security.py`](aimarket_mcp/security.py) |
| Glama / Docker (stdio) | [`Dockerfile`](Dockerfile),[`glama.json`](glama.json) |
| 自托管 HTTP | [`Dockerfile.http`](Dockerfile.http),[`docker-compose.yml`](docker-compose.yml) |
兼容主机:Claude Desktop、Cursor、Glama,以及任何支持 stdio 或 Streamable-HTTP 的 MCP 客户端。
## 工具(3)
| 工具 | 功能 | 强化 |
|------|--------------|-----------|
| `web_fetch` | 获取 URL,返回主文本(readability-lite) | SSRF 防护;输出净化 + `<untrusted>`-包装 |
| `web_search` | 直播 DuckDuckGo 搜索 → 顶部片段 | 输出净化 + `<untrusted>` |
| `metis_verify` | Metis 认知 + 验证信封 | 返回答案 + `verify_score` / `verified` 门控 |
为什么使用网关(不是每个代理的工具):通用功能只编写 **一次**;安全核心位于一个审计位置。生态系统特定的功能位于其自己的 MCP 服务器中(`aimarket-oracle-gateway`,`aimarket-plugins`)。
## 配置(环境变量)
| 变量 | 含义 |
|-----|---------|
| `AIMARKET_METIS_URL` | Metis 验证 API 基址(默认为 `https://metis.modelmarket.dev`) |
| `AIMARKET_METIS_KEY` | Metis 验证的可选 Bearer Token |
| `AIMARKET_SEARCH_URL` | DuckDuckGo HTML 端点覆盖 |
| `AIMARKET_MCP_KEY` | 仅 HTTP — Bearer Auth 密钥 |
| `AIMARKET_MCP_PRODUCTION` | 仅 HTTP — `1` 需要 `AIMARKET_MCP_KEY`(失败关闭) |
| `AIMARKET_MCP_RATE` | 仅 HTTP — 每分钟请求数/每键/IP(默认为 120) |
| `AIMARKET_MCP_PORT` | 仅 HTTP — 监听端口(默认为 9090) |
## 运行(stdio — Glama / Claude Desktop)
```bash
pip install -e .
python mcp_stdio_server.py
```
Claude Desktop (`mcpServers` 条目):
```json
{
"mcpServers": {
"aimarket-mcp": {
"command": "python",
"args": ["mcp_stdio_server.py"],
"cwd": "/path/to/aimarket-mcp"
}
}
}
```
或通过 PyPI 脚本:`aimarket-mcp`
## 运行(HTTP — 自托管)
```bash
pip install -e .
AIMARKET_MCP_KEY=sk-... AIMARKET_MCP_PRODUCTION=1 aimarket-mcp-http # :9090
# 或:docker compose up -d (使用 Dockerfile.http)
```
### Cursor / Claude(Streamable HTTP)
```json
{
"mcpServers": {
"aimarket-web": {
"type": "streamable-http",
"url": "http://127.0.0.1:9090/mcp",
"headers": {
"Authorization": "Bearer YOUR_AIMARKET_MCP_KEY"
}
}
}
}
```
## 在 Glama 上发布
列表: **[glama.ai/mcp/servers/alexar76/aimarket-mcp](https://glama.ai/mcp/servers/alexar76/aimarket-mcp)**
与 **[aimarket-oracle-gateway](https://github.com/alexar76/aimarket-oracle-gateway)**(在 Glama 上工作)相同的模式:仓库根目录 [`glama.json`](glama.json) + [`Dockerfile`](Dockerfile) + `python mcp_stdio_server.py`。
| 字段 | 值 |
|-------|--------|
| **Dockerfile** | `Dockerfile`(来自仓库 — **不是** Glama debian/uv 模板) |
| **命令** | `python mcp_stdio_server.py` |
| **占位符参数** | `{}` |
| **固定 SHA** | 空(最新) |
**不要使用** 自动生成的 `debian:trixie-slim` + `uv sync` + `mcp-proxy -- aimarket-mcp` 模板 — 那是损坏的 HTTP/ENOENT 路径。
## 消费者
- **Metis** — 启用预设:
```yaml
enable_mcp_tools: true
mcp_ecosystem_presets: [aimarket-web]
```
- **ARGUS** — 将服务器添加到 `argus.config.json` 的 `mcpServers`(参见该仓库)。
## 测试
```bash
pip install -e '.[dev]' && pytest -q
```
## Glama
Glama **忽略** 仓库 Dockerfiles — 在
[admin/dockerfile](https://glama.ai/mcp/servers/alexar76/aimarket-mcp/admin/dockerfile) 中设置 **构建步骤**:
```json
["bash scripts/glama_install.sh"]
```
CMD: `[".venv/bin/python", "mcp_stdio_server.py"]`。固定 **`main`** 或标签 **`glama-build`**(不是固定的 SHA)。详细信息:[`docs/GLAMA.md`](docs/GLAMA.md)。
## 注册表
| 注册表 | 列表 |
|----------|---------|
| **Glama** | [glama.ai/mcp/servers/alexar76/aimarket-mcp](https://glama.ai/mcp/servers/alexar76/aimarket-mcp) |
| **官方 MCP 注册表** | `io.github.alexar76/aimarket-mcp` — `server.json` + GitHub Actions |
| **PyPI** | `pip install aimarket-mcp` |
| **GitHub Releases** | [github.com/alexar76/aimarket-mcp/releases](https://github.com/alexar76/aimarket-mcp/releases) |