Skip to main content
Glama
MarveleE
by MarveleE

rap2_search_interfaces_by_keyword

Search API interfaces in RAP2 repositories using keywords to find relevant documentation and endpoints quickly.

Instructions

按关键字搜索接口(可选限定仓库)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keywordYes搜索关键字
repositoryIdNo仓库 ID(可选,传入字符串)

Implementation Reference

  • Core tool handler: Constructs query parameters for keyword (required) and optional repositoryId, performs HTTP GET to RAP2 /interface/search endpoint via _fetch, extracts and returns data array or propagates error.
    async searchInterfacesByKeyword(keyword, repositoryId) {
      const params = new URLSearchParams({ keyword: String(keyword || '') });
      if (repositoryId) params.set('repositoryId', String(repositoryId));
      const res = await this._fetch(`/interface/search?${params.toString()}`);
      const body = res?.data || {};
      if (body.errMsg) return { error: body.errMsg };
      return body.data || [];
    }
  • MCP CallToolRequest handler dispatch for this tool: Extracts and normalizes arguments using custom validators, creates Rap2Client instance, invokes core search method, logs, handles errors by throwing, returns JSON-formatted result as text content.
    if (name === 'rap2_search_interfaces_by_keyword') {
      const { keyword, repositoryId } = (req.params.arguments || {});
    
      const normalizedKeyword = validateAndNormalizeKeyword(keyword);
      const normalizedRepoId = validateAndNormalizeId('repositoryId', repositoryId, true); // 允许为空
    
      const client = createClient();
      const result = await client.searchInterfacesByKeyword(normalizedKeyword, normalizedRepoId);
    
      if (result?.error) {
        const errorMsg = String(result.error);
        logger.error({ tool: name, keyword: normalizedKeyword, repositoryId: normalizedRepoId, error: errorMsg }, 'tool failed');
        throw new Error(`搜索接口失败: ${errorMsg}`);
      }
    
      logger.info({ tool: name, keyword: normalizedKeyword, repositoryId: normalizedRepoId, resultCount: Array.isArray(result) ? result.length : 0 }, 'tool success');
      return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
  • Input schema defining the tool parameters: required 'keyword' string for search term, optional 'repositoryId' string to limit to a repository.
    inputSchema: {
      type: 'object',
      properties: {
        keyword: { type: 'string', description: '搜索关键字' },
        repositoryId: { type: 'string', description: '仓库 ID(可选,传入字符串)' },
      },
      required: ['keyword'],
    },
  • Tool definition object registered in the static tools list array, used for server capabilities.tools.list and listTools response.
    {
      name: 'rap2_search_interfaces_by_keyword',
      description: '按关键字搜索接口(可选限定仓库)',
      inputSchema: {
        type: 'object',
        properties: {
          keyword: { type: 'string', description: '搜索关键字' },
          repositoryId: { type: 'string', description: '仓库 ID(可选,传入字符串)' },
        },
        required: ['keyword'],
      },
    },
  • Helper function specifically for normalizing and validating the 'keyword' input parameter in the tool handler.
    function validateAndNormalizeKeyword(keyword) {
      if (!keyword) {
        throw new Error('参数错误: keyword 不能为空');
      }
    
      if (typeof keyword === 'string' && !keyword.trim()) {
        throw new Error('参数错误: keyword 不能是空字符串');
      }
    
      return typeof keyword === 'string' ? keyword.trim() : String(keyword);
    }
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. It only states the basic function without mentioning expected behavior like search scope (partial/full match), result format, pagination, error handling, or authentication requirements. For a search tool with zero annotation coverage, this leaves significant gaps in understanding how the tool actually behaves.

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 extremely concise - a single Chinese sentence that efficiently communicates the core functionality. Every word earns its place: '按关键字搜索接口' establishes the primary action, and '(可选限定仓库)' adds the optional constraint without redundancy. No unnecessary elaboration or structural issues exist.

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 the tool's complexity (search functionality with optional filtering), lack of annotations, and absence of output schema, the description is insufficiently complete. It doesn't explain what constitutes an 'interface' in this context, how search results are returned, what happens when no matches are found, or any limitations/constraints. The agent would need to guess about important behavioral aspects.

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?

The description mentions both parameters ('关键字搜索接口' and '可选限定仓库'), which aligns with the 100% schema description coverage. However, it doesn't add meaningful semantic context beyond what's already in the schema descriptions ('搜索关键字' and '仓库 ID(可选)'). With complete schema coverage, the baseline is 3, and the description doesn't provide additional value like search algorithm details or repository relationship context.

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: '按关键字搜索接口' (search interfaces by keyword) with optional repository limitation. It specifies both the verb ('搜索' - search) and resource ('接口' - interfaces), making the function unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'rap2_search_interfaces_by_path' or 'rap2_get_repository_interfaces', which prevents a perfect score.

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 guidance: it mentions the optional repository limitation but doesn't specify when to use this tool versus alternatives like 'rap2_search_interfaces_by_path' (path-based search) or 'rap2_get_repository_interfaces' (repository-specific listing). No explicit when-not-to-use scenarios or prerequisites are mentioned, leaving the agent with insufficient context for optimal tool selection.

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/MarveleE/rap2-mcp'

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