Skip to main content
Glama

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
NameRequiredDescriptionDefault
interfaceIdYes接口ID

Implementation Reference

  • 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,
        };
      }
    }
  • 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()),
      };
    });
  • 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,
        };
      }
    });
  • 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}`);
      }
    }
Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/abeixiaolu/yapi-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server