mcp-server-api-client
by atengk
README.md
# atengk-mcp-server-api-client
<p align="center">
<strong>面向 AI Agent 的通用 API 客户端 MCP Server(HTTP / REST / GraphQL 请求执行、OpenAPI / Swagger 解析、多环境与鉴权管理、响应断言与 cURL 互转)</strong>
</p>
<p align="center">
<a href="https://pypi.org/project/atengk-mcp-server-api-client/">
<img src="https://img.shields.io/pypi/v/atengk-mcp-server-api-client?logo=pypi&logoColor=white&style=flat-square" alt="PyPI Version" />
</a>
<a href="https://pypi.org/project/atengk-mcp-server-api-client/">
<img src="https://img.shields.io/pypi/pyversions/atengk-mcp-server-api-client?logo=python&logoColor=white&style=flat-square" alt="Python Versions" />
</a>
<a href="https://github.com/atengk/mcp-server-api-client/actions/workflows/ci.yml">
<img src="https://img.shields.io/github/actions/workflow/status/atengk/mcp-server-api-client/ci.yml?branch=main&label=CI&style=flat-square" alt="CI Status" />
</a>
<a href="https://github.com/atengk/mcp-server-api-client/releases">
<img src="https://img.shields.io/github/v/release/atengk/mcp-server-api-client?style=flat-square" alt="Release" />
</a>
<a href="./LICENSE">
<img src="https://img.shields.io/badge/License-Apache_2.0-blue.svg?style=flat-square" alt="License" />
</a>
<a href="./CONTRIBUTING.md">
<img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square" alt="PRs Welcome" />
</a>
</p>
---
## 📖 项目简介
`atengk-mcp-server-api-client` 是一款面向 AI Agent / LLM 的 Model Context Protocol (MCP) API 客户端服务端,基于 **Python 3.11+ + MCP Python SDK v2 (`MCPServer`) + `httpx` + Pydantic v2** 构建。
### 当前基线与演进规划
- **当前基线(`v0.1.0` 工程骨架)**:已完成标准化开源工程底座、CI/CD 质量门禁、提交/发版守卫及最小可运行 `MCPServer` 服务骨架(内置就绪探针工具 `ping`)。
- **规划核心能力**:
- **多协议请求执行**:基于 `httpx.AsyncClient` 的异步 HTTP/REST/GraphQL 请求调用、超时防线、连接池与流式/大响应体安全裁剪;
- **OpenAPI / Swagger 契约解析**:导入并检索接口定义、自动生成合规测试参数;
- **多环境与鉴权管理**:隔离开发/测试/生产环境变量,支持 Bearer、API Key、Basic、OAuth2 与敏感头自动脱敏;
- **响应断言与 cURL 互转**:结构化提取 JSONPath / 响应校验规则,以及与标准 `cURL` 命令的双向转换。
---
## 🛠️ 快速开始
### 1. 环境准备
请确保本地已安装:
- **Python**:`>= 3.11`
- **uv**:Python 包与虚拟环境管理工具
### 2. 本地安装与校验
```bash
# 1. 克隆仓库并激活本地提交规范钩子 (Conventional Commits 守门)
git clone https://github.com/atengk/mcp-server-api-client.git
cd mcp-server-api-client
git config core.hooksPath .githooks
# 2. 同步依赖与开发工具链
uv sync --all-extras --dev
# 3. 查看版本与命令行参数
uv run mcp-server-api-client --version
uv run mcp-server-api-client --help
# 4. 运行代码规范扫描、格式化检查与单元测试
uv run ruff check .
uv run ruff format --check .
uv run pytest
```
### 3. MCP 客户端接入示例
在支持 MCP 的客户端(如 Claude Desktop、Cursor、Antigravity 等)配置中添加本地源码启动项:
```json
{
"mcpServers": {
"api-client": {
"command": "uv",
"args": [
"--directory",
"/path/to/mcp-server-api-client",
"run",
"mcp-server-api-client"
]
}
}
}
```
### 4. 内置就绪探针工具 (`ping`)
当前骨架内置最小就绪探针工具 `ping`,用于校验 MCP 服务端实例与客户端连通性:
<!-- Tested-By: tests/test_smoke.py#test_create_mcp_server_and_call_ping_tool -->
```json
{
"status": "ok",
"server": "mcp-server-api-client",
"version": "0.1.0"
}
```
---
## 🚀 版本发版与发布
本项目基于 [`.github/workflows/release.yml`](./.github/workflows/release.yml) 实现自动化发版(前置质量门禁 + `uv build` 不可变产物 + GitHub Release + 按需分发 PyPI / GHCR 容器镜像):
1. **GitHub 网页端一键发版**:前往仓库 **Actions -> Release -> Run workflow**,填入版本号(如 `v0.1.0`)即可;
2. **原生 Git 标签发版**:`git tag -a v0.1.0 -m "Release v0.1.0" && git push origin v0.1.0`;
3. **本地防呆发版脚本**:运行 `bash scripts/release.sh --dry-run` 预检,确认后运行 `bash scripts/release.sh`(自动执行 `uv version` 递增并校验主干同步状态)。
---
## 📂 仓库目录结构
```text
.
├── .githooks/
│ └── commit-msg # Git 原生 Conventional Commits 提交校验钩子
├── .github/
│ ├── ISSUE_TEMPLATE/ # Bug 反馈与特性建议 Issue 模板
│ ├── workflows/
│ │ ├── ci.yml # Python (uv) + Ruff + ShellCheck + pytest 分层门禁
│ │ └── release.yml # 统合发版编排流水线 (Release / PyPI / GHCR)
│ ├── CODEOWNERS # PR 代码属主自动指派配置
│ ├── dependabot.yml # GitHub Actions 与 Python 依赖月度自动巡检
│ └── PULL_REQUEST_TEMPLATE.md # Pull Request 标准模板
├── scripts/
│ ├── commit.sh # 规范化提交助手 (支持交互向导与 AI 非交互调用)
│ └── release.sh # 发版防呆脚本 (支持 Pre-flight 自检与版本号递增)
├── src/
│ └── mcp_server_api_client/ # MCP Server 核心源码包
│ ├── __init__.py # 包版本元数据入口
│ ├── __main__.py # CLI 启动入口 (stdio / sse / streamable-http)
│ └── server.py # MCPServer 服务构造与工具注册
├── tests/
│ └── test_smoke.py # 基础包结构、探针工具与 CLI 冒烟测试
├── .cliff.toml # git-cliff 自动化变更日志配置
├── .dockerignore # Docker 构建上下文忽略配置
├── .editorconfig # 跨编辑器编码与缩进规范
├── .gitattributes # 跨平台换行符归一化配置 (强制 LF)
├── .gitignore # Python / uv 与通用忽略配置
├── AGENTS.md # Python (MCP SDK v2) 工程规范与 AI Agent 协作准则
├── CODE_OF_CONDUCT.md # 社区行为准则
├── CONTRIBUTING.md # 贡献指南与提交/发版规范
├── LICENSE # 开源许可证 (Apache-2.0)
├── pyproject.toml # Python 项目元数据、依赖与 Ruff/pytest 配置
├── README.md # 项目主文档
└── SECURITY.md # 安全策略与漏洞披露指南
```
---
## 🤝 参与贡献
欢迎提交 Issue 与 Pull Request!参与前请先阅读:
- [贡献指南 (CONTRIBUTING.md)](./CONTRIBUTING.md)
- [社区行为准则 (CODE_OF_CONDUCT.md)](./CODE_OF_CONDUCT.md)
- [安全策略 (SECURITY.md)](./SECURITY.md)
---
## 📄 开源许可证
本项目基于 [Apache License 2.0](./LICENSE) 协议开源。
TDQS
A3.6/5.0
Scored across 1 tool
Disambiguation4/5
With only a single tool there is nothing to confuse, so an agent cannot misselect. However, the surface provides no evidence of boundary design, so it cannot earn a top score.
Naming Consistency3/5
"ping" is a conventional, readable verb-style name, but a single tool gives no pattern to evaluate for consistency. Neutral score reflects the absence of any naming convention to judge.
Tool Count2/5
One tool is far too thin for a server billed as an "API client" — the only capability is a readiness check. There is essentially no functional surface to scope.
Completeness1/5
The server exposes no API-calling operations at all (no request, list endpoints, auth, or response handling), only a health probe. This is a severely incomplete surface for the stated purpose.
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues