关于 APISIX Mcp
APISIX MCP 服务是一个 MCP 服务器,用于将大模型与 APISIX Admin API 连接起来。它面向需要通过 MCP 兼容 AI 客户端以自然语言查看和管理 APISIX 资源的用户。
主要功能
- 01查询与删除 APISIX 资源
- 02管理路由、服务与上游
- 03管理插件配置与全局规则
- 04管理 SSL 证书与消费者凭证
- 05向网关发送请求
适用场景
- 01通过自然语言查看 APISIX 路由与服务
- 02在 AI 客户端中配置路由与上游
- 03管理插件、消费者及其凭证
MCP 相关
该项目是一个 MCP 服务器,向 MCP 客户端暴露对 APISIX Admin API 的资源管理工具,例如 get_resource、create_route 等。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
工具
32收录的工具列表 · 更新于 3 周前
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| id | string | 否 | 资源 ID |
| type | enum | 是 | 资源类型routes | services | upstreams | consumers | ssls | consumer_groups | plugin_configs | global_rules | stream_routes | protos | plugin_configs |
| page | number | 否 | 页码 |
| page_size | number | 否 | 每页数量 |
| name | string | 否 | 筛选名称 |
| labels | object | 否 | 筛选标签 |
| uri | string | 否 | 筛选 URI |
详细介绍
APISIX Model Context Protocol(MCP)服务
APISIX Model Context Protocol(MCP)服务用于连接大模型(LLM)与 APISIX Admin API。它旨在支持通过兼容 MCP 的 AI 客户端使用自然语言查看和管理 APISIX 中的资源。
https://github.com/user-attachments/assets/081e878c-225e-4ff8-a9c5-5813f4784cfe
支持的操作
常见操作
get_resource:按类型检索资源(路由、服务、上游等)delete_resource:按 ID 删除资源send_request_to_gateway:向 APISIX 网关发送一个或多个请求
API 资源操作
create_route/update_route/delete_route:管理路由create_service/update_service/delete_service:管理服务create_upstream/update_upstream/delete_upstream:管理上游create_ssl/update_ssl/delete_ssl:管理 SSL 证书create_or_update_proto:管理 protobuf 定义create_or_update_stream_route:管理流路由
插件操作
get_all_plugin_names:获取所有可用的插件名称get_plugin_info/get_plugins_by_type/get_plugin_schema:检索插件配置create_plugin_config/update_plugin_config:管理插件配置create_global_rule/update_global_rule:管理插件全局规则get_plugin_metadata/create_or_update_plugin_metadata/delete_plugin_metadata:管理插件元数据
安全配置
get_secret_by_id/create_secret/update_secret:管理密钥create_or_update_consumer/delete_consumer:管理消费者get_credential/create_or_update_credential/delete_credential/:管理消费者凭据create_consumer_group/delete_consumer_group:管理消费者组
在 AI 客户端中配置
前提条件
按照 APISIX 入门指南设置并运行 APISIX。
通过 Smithery 安装
通过 Smithery 自动为 Claude Desktop 安装 APISIX Model Context Protocol Server:
npx -y @smithery/cli install @api7/apisix-mcp --client claude
使用 npm
使用以下设置配置你的 AI 客户端(Cursor、Claude、Copilot 等):
{
"mcpServers": {
"apisix-mcp": {
"command": "npx",
"args": [
"-y",
"apisix-mcp"
],
"env": {
"APISIX_SERVER_HOST": "your-apisix-server-host",
"APISIX_SERVER_PORT": "your-apisix-server-port",
"APISIX_ADMIN_API_PORT": "your-apisix-admin-api-port",
"APISIX_ADMIN_API_PREFIX": "your-apisix-admin-api-prefix",
"APISIX_ADMIN_KEY": "your-apisix-api-key"
}
}
}
}
使用源代码
首先克隆 apisix-mcp 仓库:
git clone https://github.com/api7/apisix-mcp.git
cd apisix-mcp
安装依赖并构建项目:
pnpm install
pnpm build
使用以下设置配置你的 AI 客户端(Cursor、Claude、Copilot 等):
{
"mcpServers": {
"apisix-mcp": {
"command": "node",
"args": [
"your-apisix-mcp-path/dist/index.js"
],
"env": {
"APISIX_SERVER_HOST": "your-apisix-server-host",
"APISIX_SERVER_PORT": "your-apisix-server-port",
"APISIX_ADMIN_API_PORT": "your-apisix-admin-api-port",
"APISIX_ADMIN_API_PREFIX": "your-apisix-admin-api-prefix",
"APISIX_ADMIN_KEY": "your-apisix-api-key"
}
}
}
}
环境变量
| 变量 | 描述 | 默认值 |
|---|---|---|
APISIX_SERVER_HOST | 可访问 APISIX 服务的主机 | http://127.0.0.1 |
APISIX_SERVER_PORT | APISIX 服务端口 | 9080 |
APISIX_ADMIN_API_PORT | Admin API 端口 | 9180 |
APISIX_ADMIN_API_PREFIX | Admin API 前缀 | /apisix/admin |
APISIX_ADMIN_KEY | Admin API 身份验证密钥 | edd1c9f034335f136f87ad84b625c8f1 |
要查看或修改 APISIX 中的 Admin API 配置,请参阅 Admin API 文档。
资源
开放 MCP Marketplace API 支持
- 允许 AI 应用/Agent/大模型通过通用的 Python/TypeScript API 查找此 MCP 服务,搜索并探索相关服务和工具
示例:搜索服务和工具
import anthropic
import mcp_marketplace as mcpm
result_q = mcpm.search(query="apisix mcp", mode="list", page_id=0, count_per_page=100, config_name="deepnlp") # search server by category choose various endpoint
result_id = mcpm.search(id="api7/apisix-mcp", mode="list", page_id=0, count_per_page=100, config_name="deepnlp") # search server by id choose various endpoint
tools = mcpm.list_tools(id="api7/apisix-mcp", config_name="deepnlp_tool")
# Call Claude to Choose Tools Function Calls
client = anthropic.Anthropic()
response = client.messages.create(model="claude-3-7-sonnet-20250219", max_tokens=1024, tools=tools, messages=[])
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。
