Skip to main content
Glama

yapi_search_interface

Search for API interfaces in YApi projects by name or path to quickly find endpoint details and documentation.

Instructions

在YApi项目中搜索接口,支持按接口名称、路径搜索

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYesYApi项目ID
keywordYes搜索关键词
tokenNo访问令牌(可选)

Implementation Reference

  • The handler function for 'yapi_search_interface' tool. It calls yapiClient.searchInterface with provided arguments and returns the search results as JSON or an error message.
      async (args: { project_id: string; keyword: string; token?: string }) => {
        try {
          const results = await yapiClient.searchInterface(
            args.project_id,
            args.keyword,
            args.token
          );
    
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(results, null, 2),
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: 'text',
                text: `错误: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
            isError: true,
          };
        }
      }
    );
  • Input schema definition for the 'yapi_search_interface' tool, including parameters project_id, keyword, and optional token.
    {
      description: '在YApi项目中搜索接口,支持按接口名称、路径搜索',
      inputSchema: {
        project_id: z.string().describe('YApi项目ID'),
        keyword: z.string().describe('搜索关键词'),
        token: z.string().optional().describe('访问令牌(可选)'),
      },
    },
  • src/index.ts:575-613 (registration)
    Registration of the 'yapi_search_interface' tool using server.registerTool, including schema and handler.
    server.registerTool(
      'yapi_search_interface',
      {
        description: '在YApi项目中搜索接口,支持按接口名称、路径搜索',
        inputSchema: {
          project_id: z.string().describe('YApi项目ID'),
          keyword: z.string().describe('搜索关键词'),
          token: z.string().optional().describe('访问令牌(可选)'),
        },
      },
      async (args: { project_id: string; keyword: string; token?: string }) => {
        try {
          const results = await yapiClient.searchInterface(
            args.project_id,
            args.keyword,
            args.token
          );
    
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(results, null, 2),
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: 'text',
                text: `错误: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
            isError: true,
          };
        }
      }
    );
  • YApiClient.searchInterface helper method that makes the HTTP request to YApi's /api/interface/search endpoint to perform the interface search.
    async searchInterface(projectId: string, keyword: string, token?: string): Promise<any[]> {
      try {
        const params: any = {
          project_id: projectId,
          q: keyword,
        };
    
        // 优先使用传入的 token,其次使用实例的 token
        const finalToken = token || this.token;
        if (finalToken) {
          params.token = finalToken;
        }
    
        const response = await this.client.get('/api/interface/search', { 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 states the tool searches interfaces but doesn't disclose behavioral traits like whether it's read-only (implied but not explicit), pagination behavior, rate limits, authentication requirements (though 'token' is optional in schema), or what happens if no results are found. For a search tool with zero annotation coverage, this is a significant gap in transparency.

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: '在YApi项目中搜索接口,支持按接口名称、路径搜索'. It's front-loaded with the core purpose and includes a useful detail (search by name/path) without unnecessary elaboration. Every word earns its place, making it highly concise and well-structured.

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

Completeness3/5

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

Given the tool's moderate complexity (search function with 3 parameters), no annotations, and no output schema, the description is minimally adequate. It covers the basic purpose and search criteria but lacks details on behavior, output format, error handling, or sibling tool differentiation. It meets the bare minimum for a search tool but leaves gaps that could hinder effective agent use.

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 three parameters ('project_id', 'keyword', 'token'). The description adds marginal value by mentioning search by interface name and path, which relates to the 'keyword' parameter but doesn't provide additional syntax or format details beyond what the schema implies. Baseline 3 is appropriate 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 tool's purpose: '在YApi项目中搜索接口' (search for interfaces in YApi projects). It specifies the action (搜索/search) and resource (接口/interfaces) with scope (YApi项目中/in YApi projects). However, it doesn't explicitly differentiate from sibling tools like 'yapi_list_interfaces' or 'yapi_get_interface_by_url', which likely have different search/filtering approaches.

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?

The description provides minimal usage guidance: it mentions supporting search by interface name and path, but offers no explicit when-to-use instructions, prerequisites, or alternatives. There's no comparison with sibling tools (e.g., 'yapi_list_interfaces' might list all interfaces without filtering), leaving the agent to infer usage context.

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