mcphub_tools MCP 服务器
由 aimcp 提供支持的 McP 工具,助您轻松找到所需的 MCP。此服务器支持在 MCP Hub 中搜索可用的 MCP。
开放协议
该服务器实现了模型上下文协议 (MCP) 。它充当 MCP 服务器,可供 MCP 客户端(例如兼容的 AI 助手或开发工具)连接。
Related MCP server: MCP Server
介绍
mcphub_tools是一个用于与MCP Hub交互的 MCP 服务器。其主要功能是提供一个工具,允许用户根据关键字搜索在 Hub 上注册的 MCP(模型上下文协议/服务器)。
工具
该服务器提供以下工具:
search_mcp_hub
**描述:**在 MCP Hub 上搜索 MCP。
输入模式:
{ "type": "object", "properties": { "keywords": { "type": "string", "description": "Keywords to search for MCPs" } }, "required": ["keywords"] }**输出:**返回包含来自 MCP Hub API 的搜索结果的 JSON 字符串。
get_mcp_info
**描述:**获取有关特定 MCP 的详细信息。
输入模式:
{ "type": "object", "properties": { "id": { "type": "string", "description": "MCP identifier (UUID)" } }, "required": ["id"] }**输出:**返回包含指定 MCP 详细信息的 JSON 字符串。
实施选项
MCP Hub 支持两种不同的方式实现 MCP 服务器:
1. 基于 stdio 的标准 MCP 服务器
这是 MCP 服务器通过标准输入/输出 (stdio) 与客户端通信的传统实现方式。这种方法非常适合可与 Claude Desktop 等 MCP 客户端集成的独立命令行工具。
使用基于 stdio 的实现的最简单方法是通过我们发布的包:
# Using npx (recommended for most users)
npx @aimcp/tools
# Using uvx (faster startup)
uvx @aimcp/tools2. 基于 HTTP 的 MCP 服务器
MCP Hub 还提供了基于 HTTP 的实现,允许 AI 助手和其他工具通过 HTTP 连接到 MCP 服务器。该实现在 MCP Hub 的 API 中,位于/api/open/v1/streamable 。
HTTP 端点位于:
https://mcp.aimcp.info/api/open/v1/streamable用法
先决条件
为基于 stdio 的实现安装 Node.js 和 npm(或 pnpm/yarn)。
来自 MCP Hub 的 API 密钥( https://www.aimcp.info )。
如何获取 API 密钥
注册或登录。
导航到您的个人资料或帐户设置。
寻找生成或检索 API 密钥的选项。
或者您可以访问此处生成 API 密钥。注意:API 密钥的请求速率限制为每小时 20 个。
验证
MCP API 需要使用有效的 API 密钥进行身份验证。此密钥必须通过以下方式提供:
对于基于 stdio 的实现:环境变量
MCP_HUB_API_KEY。对于基于 HTTP 的实现:
Authorization标头作为 Bearer 令牌。
Authorization: Bearer YOUR_API_KEY与 AI 助手和 MCP 客户端集成
Claude桌面配置
要将 MCP Hub 与 Claude Desktop 结合使用:
找到您的 Claude Desktop 配置文件:
Windows:
%APPDATA%\claude\config.jsonmacOS:
~/Library/Application Support/claude/config.json或~/.config/claude/config.jsonLinux:
~/.config/claude/config.json
添加以下配置:
{
"mcpServers": {
"mcp-hub": {
"command": "npx",
"args": ["@aimcp/tools"],
"environment": {
"MCP_HUB_API_KEY": "YOUR_API_KEY"
}
}
}
}重新启动 Claude Desktop 以应用更改。
在对话中,您可以通过输入“@mcp-hub”来访问 MCP Hub 工具。
Cline 和其他 CLI 工具
对于基于命令行的工具(例如 Cline):
在您的项目目录中创建一个名为
servers.json的配置文件:
{
"servers": [
{
"name": "mcp-hub-tools",
"command": ["npx", "@aimcp/tools"],
"environment": {
"MCP_HUB_API_KEY": "YOUR_API_KEY"
}
}
]
}参考此配置启动该工具:
cline --mcp-servers-config ./servers.json对于支持远程 MCP 服务器的工具
一些较新的 MCP 客户端支持直接 HTTP 连接。请使用以下方式配置它们:
{
"mcpServers": {
"mcp-hub-http": {
"url": "https://mcp.aimcp.info/api/open/v1/streamable",
"headers": {
"Authorization": "Bearer YOUR_API_KEY"
}
}
}
}对于使用基于文件配置的工具(光标等)
创建配置文件:
{
"mcpServers": {
"mcp-hub": {
"command": "npx",
"args": ["@aimcp/tools"],
"environment": {
"MCP_HUB_API_KEY": "YOUR_API_KEY"
}
}
}
}在您的工具设置中引用此文件或使用适当的配置参数启动。
手动运行
您还可以手动运行基于 stdio 的服务器进行测试(确保在您的环境中设置了MCP_HUB_API_KEY ):
export MCP_HUB_API_KEY="YOUR_API_KEY_HERE"
npx @aimcp/toolsAPI接口
该服务器与以下 MCP Hub API 端点交互:
端点:
GET https://www.aimcp.info/api/open/v1/search**身份验证:**需要使用
MCP_HUB_API_KEY在Authorization标头中输入 Bearer 令牌。查询参数:
keywords(字符串)
使用基于 HTTP 的 MCP API
MCP Hub 在/api/open/v1/streamable提供了一个基于 HTTP 的 MCP 服务器,该服务器实现了模型上下文协议 (MCP Protocol)。这使得 AI 助手和工具能够直接搜索 MCP 并获取 MCP 信息。
连接步骤
首先建立连接以获取会话ID:
GET /api/open/v1/streamable
Authorization: Bearer YOUR_API_KEY回复:
{
"success": true,
"sessionId": "194830ab-eb0b-4d17-a574-af96705276c2",
"message": "Connection established. Use this sessionId for subsequent calls."
}使用会话 ID 调用工具:
POST /api/open/v1/streamable?sessionId=194830ab-eb0b-4d17-a574-af96705276c2
Content-Type: application/json
Authorization: Bearer YOUR_API_KEY
{
"jsonrpc": "2.0",
"method": "callTool",
"params": {
"name": "search_mcp_hub",
"arguments": {
"keywords": "example"
}
},
"id": "call-1"
}开发与部署
发展
安装依赖项:
pnpm install构建:
pnpm run build(在build/中将 TypeScript 编译为 JavaScript)监视模式:
pnpm run watch(发生更改时自动重新编译)使用 Inspector 进行测试:
pnpm run inspector(使用 MCP Inspector 工具运行服务器)
创建你自己的基于 stdio 的 MCP 服务器
如果您想创建自己的基于 stdio 的 MCP 服务器,请按照以下步骤操作:
设置您的项目:
mkdir my-mcp-server cd my-mcp-server npm init -y npm install @modelcontextprotocol/sdk创建您的服务器实现:
// index.ts
import { Server } from '@modelcontextprotocol/sdk/server';
import {
CallToolRequestSchema,
ListToolsRequestSchema,
McpError,
ErrorCode
} from '@modelcontextprotocol/sdk/types';
import { StdioTransport } from '@modelcontextprotocol/sdk/transports/stdio';
// Create an MCP server instance
const server = new Server(
{
name: "my-mcp-server",
version: "1.0.0"
},
{
capabilities: {
tools: {},
}
}
);
// Set up tool handlers
server.setRequestHandler(ListToolsRequestSchema, async () => ({
tools: [
{
name: 'my_tool',
description: 'Description of my tool',
inputSchema: {
type: 'object',
properties: {
param1: {
type: 'string',
description: 'Description of param1',
},
},
required: ['param1'],
},
},
],
}));
server.setRequestHandler(CallToolRequestSchema, async (request) => {
// Extract tool name and arguments
const toolName = request.params.name;
const args = request.params.arguments;
if (toolName === 'my_tool') {
// Validate arguments
if (typeof args !== 'object' || args === null || typeof args.param1 !== 'string') {
throw new McpError(
ErrorCode.InvalidParams,
'Invalid arguments. Requires "param1" (string).'
);
}
try {
// Implement your tool logic here
const result = `Processed: ${args.param1}`;
return {
content: [
{
type: 'text',
text: result,
},
],
};
} catch (error) {
return {
content: [
{
type: 'text',
text: `Error: ${error instanceof Error ? error.message : String(error)}`,
},
],
isError: true,
};
}
} else {
throw new McpError(
ErrorCode.MethodNotFound,
`Unknown tool: ${toolName}`
);
}
});
// Connect the server to stdin/stdout
const transport = new StdioTransport();
server.connect(transport).catch(console.error);编译并运行你的服务器:
npx tsc node dist/index.js使用 MCP Inspector 工具测试您的服务器:
npx @modelcontextprotocol/inspector
部署
确保服务器已构建(
pnpm run build)。build目录包含必要的 JavaScript 文件。如果软件包安装得当(例如全局或链接),则可以使用
node build/index.js或命令mcphub_tools运行服务器。配置您的 MCP 客户端/管理器以指向服务器可执行文件并提供
MCP_HUB_API_KEY环境变量。
您还可以将您的 MCP 服务器发布到 npm,以便其他人可以安装和使用它。