Skip to main content
Glama
MarveleE
by MarveleE

rap2_search_interfaces_by_path

Search RAP2 API interfaces by request path to find documentation details. Optionally filter results by repository ID for targeted queries.

Instructions

按请求路径搜索接口(可选限定仓库)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes请求路径(如:/api/users)
repositoryIdNo仓库 ID(可选,传入字符串)

Implementation Reference

  • MCP server-side handler for the 'rap2_search_interfaces_by_path' tool call. Validates and normalizes input parameters (path and optional repositoryId), creates a Rap2Client instance, invokes the client's searchInterfacesByPath method, handles errors with logging, and returns the JSON-formatted result.
    if (name === 'rap2_search_interfaces_by_path') {
      const { path, repositoryId } = (req.params.arguments || {});
    
      const normalizedPath = validateAndNormalizeKeyword(path);
      const normalizedRepoId = validateAndNormalizeId('repositoryId', repositoryId, true); // 允许为空
    
      const client = createClient();
      const result = await client.searchInterfacesByPath(normalizedPath, normalizedRepoId);
    
      if (result?.error) {
        const errorMsg = String(result.error);
        logger.error({ tool: name, path: normalizedPath, repositoryId: normalizedRepoId, error: errorMsg }, 'tool failed');
        throw new Error(`按路径搜索接口失败: ${errorMsg}`);
      }
    
      logger.info({ tool: name, path: normalizedPath, repositoryId: normalizedRepoId, resultCount: Array.isArray(result) ? result.length : 0 }, 'tool success');
      return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
    }
  • Registration of the 'rap2_search_interfaces_by_path' tool in the MCP server's tools array, including description and input schema definition.
    {
      name: 'rap2_search_interfaces_by_path',
      description: '按请求路径搜索接口(可选限定仓库)',
      inputSchema: {
        type: 'object',
        properties: {
          path: { type: 'string', description: '请求路径(如:/api/users)' },
          repositoryId: { type: 'string', description: '仓库 ID(可选,传入字符串)' },
        },
        required: ['path'],
      },
    },
  • Core helper method in Rap2Client class that implements the tool logic: builds query params for 'path' and optional 'repositoryId', performs HTTP fetch to the RAP2 /interface/search endpoint, and processes the response handling errors.
    async searchInterfacesByPath(path, repositoryId) {
      const params = new URLSearchParams({ path: String(path || '') });
      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 || [];
    }

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