Skip to main content
Glama
MarveleE
by MarveleE

rap2_get_interface_by_id

Retrieve detailed API interface specifications by providing the interface ID to access documentation parameters, endpoints, and requirements.

Instructions

根据接口 ID 获取接口详情

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
interfaceIdYes接口 ID(传入字符串,内部会规范化)

Implementation Reference

  • Handler for rap2_get_interface_by_id tool: validates interfaceId, invokes Rap2Client.getInterfaceById, logs, handles errors, returns JSON response.
    if (name === 'rap2_get_interface_by_id') { const { interfaceId } = (req.params.arguments || {}); const normalizedId = validateAndNormalizeId('interfaceId', interfaceId); const client = createClient(); const result = await client.getInterfaceById(normalizedId); if (result?.error) { const errorMsg = String(result.error); logger.error({ tool: name, interfaceId: normalizedId, error: errorMsg }, 'tool failed'); throw new Error(`获取接口失败: ${errorMsg}`); } logger.info({ tool: name, interfaceId: normalizedId, resultType: typeof result, hasData: !!result }, 'tool success'); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; }
  • Core implementation: HTTP fetch to /interface/get?id=, parses response, returns interface data or error.
    async getInterfaceById(interfaceId) { const res = await this._fetch(`/interface/get?id=${encodeURIComponent(interfaceId)}`); const ok = res?.data; if (!ok) return { error: '空响应' }; if (ok.errMsg) return { error: ok.errMsg }; return ok.data || ok; }
  • Tool registration in tools list: defines name, description, and input schema.
    { name: 'rap2_get_interface_by_id', description: '根据接口 ID 获取接口详情', inputSchema: { type: 'object', properties: { interfaceId: { type: 'string', description: '接口 ID(传入字符串,内部会规范化)' }, }, required: ['interfaceId'], }, },
  • Input schema definition for the tool.
    inputSchema: { type: 'object', properties: { interfaceId: { type: 'string', description: '接口 ID(传入字符串,内部会规范化)' }, }, required: ['interfaceId'], },
  • Utility function used in handler to validate and normalize interfaceId.
    function validateAndNormalizeId(paramName, value, allowEmpty = false) { if (value === null || value === undefined) { if (!allowEmpty) { throw new Error(`参数错误: ${paramName} 不能为空`); } return undefined; } let normalized; if (typeof value === 'number') { normalized = String(value); } else if (typeof value === 'string') { if (!value.trim()) { if (!allowEmpty) { throw new Error(`参数错误: ${paramName} 不能是空字符串`); } return undefined; } normalized = value.trim(); } else { throw new Error(`参数错误: ${paramName} 必须是数字或字符串,收到的是 ${typeof value}`); } // 验证ID格式 if (normalized && !/^\d+$/.test(normalized)) { throw new Error(`参数错误: ${paramName} 必须是有效的数字字符串,收到的是 "${normalized}"`); } return normalized; }

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