Skip to main content
Glama

apipost_detail

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

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
target_idYes要查看的接口ID

Implementation Reference

  • src/index.ts:946-956 (registration)
    Tool registration including name, description, and input schema for apipost_detail
    name: 'apipost_detail', description: '查看API接口的详细配置信息,包括完整的请求参数、响应格式、认证设置等。', inputSchema: { type: 'object', properties: { target_id: { type: 'string', description: '要查看的接口ID' } }, required: ['target_id'], additionalProperties: false } },
  • The main handler for the apipost_detail tool. Fetches API details via ApiPost API and formats a comprehensive text summary of the API configuration including basic info, headers, query, body, cookies, auth, and responses.
    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 }] };

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