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;
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action but doesn't describe what '详情' (details) includes, whether it's a read-only operation, if it requires authentication, or any error conditions. This leaves significant gaps in understanding the tool's behavior beyond the basic action.

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 that directly states the tool's purpose without unnecessary words. It's front-loaded with the core action and resource, making it easy to parse quickly.

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 lack of annotations and output schema, the description is incomplete. It doesn't explain what '接口详情' includes in the response, potential error cases, or dependencies on other tools like 'rap2_ensure_session'. For a tool with no structured behavioral data, more context is needed to guide effective 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?

The schema description coverage is 100%, with the parameter 'interfaceId' fully documented in the schema as '接口 ID(传入字符串,内部会规范化)'. The description adds no additional parameter semantics beyond what the schema provides, so it meets the baseline for high schema coverage without adding value.

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 ('获取接口详情' - get interface details) and the resource ('根据接口 ID' - by interface ID), making the purpose unambiguous. However, it doesn't differentiate from sibling tools like 'rap2_get_repository_interfaces' or 'rap2_search_interfaces_by_keyword', which also retrieve interface information but through different mechanisms.

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 no guidance on when to use this tool versus alternatives like 'rap2_search_interfaces_by_keyword' or 'rap2_get_repository_interfaces'. It lacks context about prerequisites (e.g., whether a session is required) or exclusions, leaving the agent to infer usage from the tool name alone.

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