MCP-FEISHU

by NINGyv179
Verified
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { z } from "zod"; import feishuService from './feishuService.js'; class Server { private server: McpServer; constructor() { // Initialize the MCP server this.server = new McpServer({ name: 'Fei Shu', version: '1.0.0', description: 'MCP server for feishu OpenAPI integration', capabilities: { // Define server capabilities here api_testing: true, api_documentation: true } }); // Register handlers for MCP methods this.registerTools(); } /** * Get the MCP server instance */ getServer(): McpServer { return this.server; } /** * Register handlers for MCP methods */ private registerTools(): void { // Register tool handlers using the new SDK pattern this.server.tool( "get_defect_link", { ID: z.string(), }, async ({ ID }) => { const token = await feishuService.getRecord('ID', ID); return { content: [{ type: "text", text: JSON.stringify({ token }, null, 2) }] }; } ); this.server.tool( "get_recently_updated_defect_list", { status: z.string(), startDate: z.number(), endDate: z.number(), }, async ({ status, startDate, endDate }) => { const records = await feishuService.getRecordsByStatus(status, startDate, endDate); return { content: [{ type: "text", text: JSON.stringify({ records }, null, 2) }] }; } ); } } // Export a singleton instance export default new Server();