Skip to main content
Glama

yapi_list_interfaces

Retrieve API interface lists from YApi projects or categories to organize and access documentation efficiently within MCP-compatible editors.

Instructions

获取YApi项目或分类下的接口列表

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYesYApi项目ID
cat_idNo分类ID(可选)
tokenNo访问令牌(可选)

Implementation Reference

  • The handler function for the yapi_list_interfaces tool. It calls yapiClient.getInterfaceList with the provided arguments and returns the interfaces as JSON text, or an error message.
    async (args: { project_id: string; cat_id?: string; token?: string }) => {
      try {
        const interfaces = await yapiClient.getInterfaceList(
          args.project_id,
          args.cat_id,
          args.token
        );
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(interfaces, null, 2),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `错误: ${error instanceof Error ? error.message : String(error)}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Input schema definition for the yapi_list_interfaces tool using Zod, defining project_id as required string, cat_id and token as optional.
    {
      description: '获取YApi项目或分类下的接口列表',
      inputSchema: {
        project_id: z.string().describe('YApi项目ID'),
        cat_id: z.string().optional().describe('分类ID(可选)'),
        token: z.string().optional().describe('访问令牌(可选)'),
      },
    },
  • src/index.ts:534-572 (registration)
    Registration of the yapi_list_interfaces tool on the MCP server using server.registerTool, including name, schema, and inline handler.
    server.registerTool(
      'yapi_list_interfaces',
      {
        description: '获取YApi项目或分类下的接口列表',
        inputSchema: {
          project_id: z.string().describe('YApi项目ID'),
          cat_id: z.string().optional().describe('分类ID(可选)'),
          token: z.string().optional().describe('访问令牌(可选)'),
        },
      },
      async (args: { project_id: string; cat_id?: string; token?: string }) => {
        try {
          const interfaces = await yapiClient.getInterfaceList(
            args.project_id,
            args.cat_id,
            args.token
          );
    
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(interfaces, null, 2),
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: 'text',
                text: `错误: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
            isError: true,
          };
        }
      }
    );
  • YApiClient.getInterfaceList method, the core helper function that fetches the interface list from YApi API via axios, handling project or category endpoints and authentication.
    async getInterfaceList(projectId: string, catId?: string, token?: string): Promise<any[]> {
      try {
        let endpoint: string;
        const params: any = {};
    
        if (catId) {
          endpoint = '/api/interface/list_cat';
          params.catid = catId;
        } else {
          endpoint = '/api/interface/list';
          params.project_id = projectId;
        }
    
        // 优先使用传入的 token,其次使用实例的 token
        const finalToken = token || this.token;
        if (finalToken) {
          params.token = finalToken;
        }
    
        const response = await this.client.get(endpoint, { params });
    
        if (response.data.errcode !== 0) {
          throw new Error(response.data.errmsg || '获取接口列表失败');
        }
    
        return response.data.data || [];
      } catch (error) {
        this.handleError(error, '获取接口列表失败');
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions '获取' (get) which suggests a read operation, but doesn't disclose behavioral traits like authentication needs (token parameter is optional but not explained), rate limits, pagination, or what the output looks like (no output schema). For a list operation with no annotations, this is a significant gap.

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 sentence in Chinese that directly states the tool's purpose without any fluff. It's appropriately sized and front-loaded, with every word contributing to understanding the action and scope.

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?

Given no annotations, no output schema, and 3 parameters (with 100% schema coverage but no behavioral context), the description is incomplete. It doesn't explain the return format, error handling, or how to interpret results (e.g., list structure). For a list tool with siblings, more context on usage and output is needed.

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%, so the schema already documents all parameters (project_id, cat_id, token). The description adds no additional meaning beyond what's in the schema (e.g., it doesn't explain relationships between project_id and cat_id or token usage). Baseline is 3 when schema does the heavy lifting.

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 ('获取' meaning 'get') and resource ('接口列表' meaning 'interface list') with scope ('YApi项目或分类下' meaning 'under YApi project or category'). It distinguishes from siblings like yapi_get_interface (single interface) and yapi_search_interface (search), but doesn't explicitly mention these distinctions. The purpose is specific and actionable.

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

Usage Guidelines2/5

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

No guidance on when to use this tool versus alternatives like yapi_search_interface or yapi_get_interface_by_url. The description implies it lists interfaces under a project or category, but doesn't specify scenarios (e.g., for browsing vs. searching) or prerequisites. Usage is implied from context but not explicitly stated.

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/TStoneLee/mcp-yapi-server'

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