yapi-get-interface
Retrieve API interface details from YApi documentation using an interface ID to access specifications, parameters, and endpoint information.
Instructions
根据接口ID获取接口详情
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| interfaceId | Yes | 接口ID |
Implementation Reference
- src/tools/yapiTools.ts:53-75 (handler)Core handler function that retrieves the interface details by ID from YApiClient and formats the response.private async getInterface(interfaceId: number) { try { const interface_ = await this.yapiClient.getInterface(interfaceId); return { content: [ { type: "text", text: JSON.stringify(interface_, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error: ${error instanceof Error ? error.message : "Unknown error"}`, }, ], isError: true, }; } }
- src/tools/yapiTools.ts:9-22 (schema)Tool schema definition including name, description, and input schema requiring 'interfaceId'."yapi-get-interface": { name: "yapi-get-interface", description: "根据接口ID获取接口详情", inputSchema: { type: "object", properties: { interfaceId: { type: "number", description: "接口ID", }, }, required: ["interfaceId"], }, },
- src/index.ts:46-50 (registration)Registers the tool by including it in the list of tools returned by ListToolsRequestHandler.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: Object.values(yapiTools.getToolDefinitions()), }; });
- src/index.ts:52-72 (handler)MCP server handler for tool calls, which delegates to YApiTools.handleToolCall for execution.server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; if (!name) { throw new Error("Tool name is required"); } try { return await yapiTools.handleToolCall(name, args); } catch (error) { return { content: [ { type: "text", text: `Error: ${error instanceof Error ? error.message : "Unknown error"}`, }, ], isError: true, }; } });
- src/tools/yapiTools.ts:40-51 (handler)Tool dispatcher that routes 'yapi-get-interface' calls to the getInterface handler.async handleToolCall(toolName: string, args: any): Promise<any> { switch (toolName) { case "yapi-get-interface": return await this.getInterface(args.interfaceId); case "yapi-get-interface-by-url": return await this.getInterfaceByUrl(args.url); default: throw new Error(`Unknown tool: ${toolName}`); } }