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}`);
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. While '获取' (get) implies a read operation, the description doesn't specify authentication requirements, rate limits, error conditions, response format, or whether this is a safe/idempotent operation. It provides minimal behavioral context beyond the basic action.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient Chinese sentence that communicates the core functionality without any wasted words. It's appropriately sized for a simple lookup tool with one parameter and gets straight to the point.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what '接口详情' (interface details) includes in the response, doesn't mention error handling for invalid IDs, and provides minimal behavioral context. Given the lack of structured metadata, the description should do more to compensate.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the single parameter 'interfaceId' documented as '接口ID' (interface ID). The description adds no additional parameter semantics beyond what's already in the schema. The baseline score of 3 is appropriate when the schema provides complete parameter documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('获取' - get/retrieve) and resource ('接口详情' - interface details) with the specific condition '根据接口ID' (based on interface ID). It distinguishes from the sibling tool 'yapi-get-interface-by-url' by specifying ID-based lookup rather than URL-based lookup. However, it doesn't explicitly name the sibling alternative.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context through '根据接口ID' (based on interface ID), suggesting this tool should be used when you have an interface ID rather than a URL. However, it doesn't explicitly state when to use this vs. the sibling 'yapi-get-interface-by-url' or provide any exclusion criteria or prerequisites.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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