mcpField
P
Pocha MCP Server

Pocha MCP Server

本地服务
github.com/retz8开发工具084 周前更新

关于 Pocha MCP Server

Pocha MCP Server 为 Pocha 项目生成带类型的 TypeScript API 函数模板,面向需要统一函数模式的开发团队。生成内容支持 HTTP 方法、身份验证和错误处理。

主要功能

  1. 01生成带类型的 TypeScript API 函数
  2. 02支持 GET、POST、PUT 和 DELETE
  3. 03处理身份验证令牌
  4. 04包含错误处理和响应类型
  5. 05支持可选参数与返回类型

适用场景

  1. 01为 Pocha API 路由创建带类型的函数
  2. 02生成错误处理一致的 API 模板

MCP 相关

MCP 服务提供 generate-api-function 工具,可接收函数信息,包括路由、HTTP 方法和可选参数。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

暂未收录安装方式

我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。

代码仓库

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍

Pocha MCP 服务

一个为 Pocha 项目生成 TypeScript API 函数的模型上下文协议(MCP)服务。此服务提供了一个工具,可按照一致的模式自动生成类型安全的 API 函数模板。

功能

  • 生成类型规范的 TypeScript API 函数
  • 支持 GET、POST、PUT、DELETE HTTP 方法
  • 包含身份验证令牌处理
  • 生成规范的错误处理和响应类型
  • 支持可选参数和返回类型

安装

# Clone the repository
git clone https://github.com/jiohjung98/pocha-mcp-server.git

# Install dependencies
pnpm install

# Build the project
pnpm build

使用方法

此服务提供了一个名为 generate-api-function 的工具,接受以下参数:

{
  functionName: string;          // Name of the API function to generate
  route: string;                 // API route path (e.g., "/pocha/${pochaid}")
  method: "GET" | "POST" | "PUT" | "DELETE";  // HTTP method
  params?: {                     // Optional array of parameters
    name: string;               // Parameter name
    type: string;               // Parameter type
  }[];
  returnType: string;           // Return type of the API function
}
示例

生成一个用于获取 Pocha 信息的 API 函数:

// Input parameters
{
  "functionName": "getPocha",
  "route": "/pocha/${pochaid}",
  "method": "GET",
  "params": [
    {
      "name": "pochaid",
      "type": "number"
    }
  ],
  "returnType": "PochaInfo"
}

// Generated output
/**
 * @desc getPocha
 * @route GET /pocha/${pochaid}
 */
export async function getPocha(pochaid: number, token: string): Promise<PochaInfo> {
  const url = `/pocha/${pochaid}`;
  try {
    const response = await client.get(url, {
      headers: {
        Authorization: `Bearer ${token}`,
      },
    });

    return response?.data;
  } catch (error) {
    console.log(error);
    throw new Error("Error in getPocha");
  }
}

开发

此服务使用以下技术构建:

  • TypeScript
  • MCP TypeScript SDK
  • 用于架构验证的 Zod

开始开发:

# Install dependencies
pnpm install

# Build in watch mode
pnpm dev

项目结构

pocha-mcp-server/
├── src/
│   └── index.ts     # Main server implementation
├── dist/            # Compiled JavaScript
├── package.json
└── tsconfig.json

Cursor 设置

要在 Cursor IDE 中使用此 MCP 服务:

  1. 打开 Cursor MCP 配置文件:

    # macOS
    ~/.cursor/mcp.json
    
    # Windows
    %APPDATA%/cursor/mcp.json
    
    # Linux
    ~/.cursor/mcp.json
    
  2. 将以下配置添加到 mcpServers 对象中:

    {
      "mcpServers": {
        "pocha-api-generator": {
          "command": "/opt/homebrew/bin/npx",
          "args": ["-y", "node", "/path/to/your/pocha-mcp-server/dist/index.js"]
        }
      }
    }
    

    将 /path/to/your/pocha-mcp-server 替换为克隆此仓库的实际路径。

  3. 重启 Cursor 以使更改生效。

  4. 此 MCP 服务现在将在 Cursor 中可用,你可以通过输入如下自然语言命令来使用它生成 API 函数:

    Can you create a sample API for pocha project that fetches PochaInfo from "/pocha/${pochaid}" using "pocha-api-generator" mcp?
    

许可证

MIT 许可证

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。