Skip to main content
Glama

apipost_detail

Retrieve complete API interface configuration details including request parameters, response formats, and authentication settings for API documentation management.

Instructions

查看API接口的详细配置信息,包括完整的请求参数、响应格式、认证设置等。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
target_idYes要查看的接口ID

Implementation Reference

  • Handler implementation for 'apipost_detail' tool. Fetches API details from ApiPost using /open/apis/details endpoint, formats the response including basic info, headers, query, body, cookies, auth, and responses into a detailed text summary.
    case 'apipost_detail':
        if (!checkSecurityPermission('read')) {
            throw new Error(`🔒 安全模式 "${APIPOST_SECURITY_MODE}" 不允许读取操作。`);
        }
        const detailTargetId = args.target_id;
        if (!detailTargetId) {
            throw new Error('请提供要查看的API接口ID');
        }
        // 获取接口详情
        const detailResult = await apiClient.post('/open/apis/details', {
            project_id: currentWorkspace.projectId,
            target_ids: [detailTargetId]
        });
        if (detailResult.data.code !== 0) {
            throw new Error(`获取接口详情失败: ${detailResult.data.msg}`);
        }
        const apiDetail = detailResult.data.data.list[0];
        if (!apiDetail) {
            throw new Error(`未找到接口详情 (ID: ${detailTargetId})。可能原因:1) 接口不存在 2) 无权限访问 3) 接口已被删除。请检查接口ID是否正确。`);
        }
        // 格式化接口详情
        let detailText = `📋 接口详情\n\n`;
        detailText += `🏷️  基本信息\n`;
        detailText += `   接口名称: ${apiDetail.name}\n`;
        detailText += `   请求方法: ${apiDetail.method}\n`;
        detailText += `   请求URL: ${apiDetail.url}\n`;
        detailText += `   接口ID: ${detailTargetId}\n`;
        detailText += `   版本: v${apiDetail.version || 1}\n`;
        if (apiDetail.description) {
            detailText += `   描述: ${apiDetail.description}\n`;
        }
        detailText += `\n`;
        // Headers参数
        const headers = apiDetail.request?.header?.parameter || [];
        detailText += `📨 Headers参数 (${headers.length}个)\n`;
        if (headers.length > 0) {
            headers.forEach((header, index) => {
                detailText += `   ${index + 1}. ${header.key}: ${header.description || '无描述'}\n`;
                detailText += `      类型: ${header.field_type || 'string'}, 必需: ${header.not_null ? '是' : '否'}\n`;
                if (header.value)
                    detailText += `      示例: ${header.value}\n`;
            });
        }
        else {
            detailText += `   (无Headers参数)\n`;
        }
        detailText += `\n`;
        // Query参数
        const queryParams = apiDetail.request?.query?.parameter || [];
        detailText += `🔍 Query参数 (${queryParams.length}个)\n`;
        if (queryParams.length > 0) {
            queryParams.forEach((param, index) => {
                detailText += `   ${index + 1}. ${param.key}: ${param.description || '无描述'}\n`;
                detailText += `      类型: ${param.field_type || 'string'}, 必需: ${param.not_null ? '是' : '否'}\n`;
                if (param.value)
                    detailText += `      示例: ${param.value}\n`;
            });
        }
        else {
            detailText += `   (无Query参数)\n`;
        }
        detailText += `\n`;
        // Body参数
        const bodyParams = apiDetail.request?.body?.raw_parameter || [];
        detailText += `📝 Body参数 (${bodyParams.length}个)\n`;
        if (bodyParams.length > 0) {
            bodyParams.forEach((param, index) => {
                detailText += `   ${index + 1}. ${param.key}: ${param.description || '无描述'}\n`;
                detailText += `      类型: ${param.field_type || 'string'}, 必需: ${param.not_null ? '是' : '否'}\n`;
                if (param.value)
                    detailText += `      示例: ${param.value}\n`;
            });
        }
        else {
            detailText += `   (无Body参数)\n`;
        }
        detailText += `\n`;
        // Cookies参数
        const cookies = apiDetail.request?.cookie?.parameter || [];
        detailText += `🍪 Cookies参数 (${cookies.length}个)\n`;
        if (cookies.length > 0) {
            cookies.forEach((cookie, index) => {
                detailText += `   ${index + 1}. ${cookie.key}: ${cookie.description || '无描述'}\n`;
                detailText += `      类型: ${cookie.field_type || 'string'}, 必需: ${cookie.not_null ? '是' : '否'}\n`;
                if (cookie.value)
                    detailText += `      示例: ${cookie.value}\n`;
            });
        }
        else {
            detailText += `   (无Cookies参数)\n`;
        }
        detailText += `\n`;
        // 认证配置
        const auth = apiDetail.request?.auth || {};
        detailText += `🔐 认证配置\n`;
        if (auth.type && auth.type !== 'inherit') {
            detailText += `   类型: ${auth.type}\n`;
            if (auth.bearer?.key) {
                detailText += `   Token: ${auth.bearer.key.substring(0, 20)}...\n`;
            }
        }
        else {
            detailText += `   (继承父级认证或无认证)\n`;
        }
        detailText += `\n`;
        // 响应示例
        const responses = apiDetail.response?.example || [];
        detailText += `📤 响应示例 (${responses.length}个)\n`;
        if (responses.length > 0) {
            responses.forEach((resp, index) => {
                detailText += `   ${index + 1}. ${resp.expect?.name || '响应' + (index + 1)}\n`;
                detailText += `      状态码: ${resp.expect?.code || 200}\n`;
                if (resp.raw) {
                    const rawData = resp.raw.length > 200 ? resp.raw.substring(0, 200) + '...' : resp.raw;
                    detailText += `      数据: ${rawData}\n`;
                }
            });
        }
        else {
            detailText += `   (无响应示例)\n`;
        }
    
        return {
            content: [{ type: 'text', text: detailText }]
        };
  • src/index.ts:946-956 (registration)
    Registration of 'apipost_detail' tool in the listTools handler, including name, description, and input schema requiring 'target_id'.
        name: 'apipost_detail',
        description: '查看API接口的详细配置信息,包括完整的请求参数、响应格式、认证设置等。',
        inputSchema: {
            type: 'object',
            properties: {
                target_id: { type: 'string', description: '要查看的接口ID' }
            },
            required: ['target_id'],
            additionalProperties: false
        }
    },
  • Input schema for 'apipost_detail' tool, defining a single required 'target_id' string property.
    inputSchema: {
        type: 'object',
        properties: {
            target_id: { type: 'string', description: '要查看的接口ID' }
        },
        required: ['target_id'],
        additionalProperties: false
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool views detailed configuration information, implying a read-only operation, but doesn't clarify if it requires authentication, has rate limits, returns structured data, or handles errors. The description lacks details on behavioral traits beyond the basic action, leaving gaps for an AI agent to understand how to invoke it correctly.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/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 and scope. It's front-loaded with the main action and includes specific details (request parameters, response format, authentication settings) without unnecessary elaboration. However, it could be slightly more structured by separating usage context, but it's appropriately sized with zero waste.

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 complexity (a read operation with 1 parameter), no annotations, and no output schema, the description is minimally adequate. It covers what the tool does but lacks behavioral context (e.g., authentication needs, error handling) and output details. It's complete enough for basic understanding but has clear gaps that could hinder an AI agent's ability to use it effectively without additional inference.

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 input schema has 1 parameter with 100% description coverage ('要查看的接口ID' - the interface ID to view). The description adds no additional meaning beyond the schema, as it doesn't explain parameter usage, format, or examples. With high schema coverage, the baseline is 3, and the description doesn't compensate or add value, so it scores 3.

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: '查看API接口的详细配置信息' (view detailed configuration information of an API interface). It specifies the resource (API interface) and the action (view detailed configuration), which includes request parameters, response format, and authentication settings. However, it doesn't explicitly differentiate from sibling tools like 'apipost_list' (which might list interfaces without details) or 'apipost_test_connection' (which might test connectivity rather than show configuration).

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. It doesn't mention prerequisites (e.g., needing an interface ID), exclusions (e.g., not for creating or updating interfaces), or comparisons to siblings like 'apipost_list' (for listing) or 'apipost_update' (for modifying). Usage is implied only by the action 'view,' but no explicit context is given.

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/jlcodes99/apipost-mcp'

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