apipost_create_folder
Create API documentation folders to organize endpoints and resources within the ApiPost MCP server. Specify parent directories and add descriptions for structured project management.
Instructions
创建API文档目录,支持在指定父目录下创建新的文件夹
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | 目录名称 | |
| parent_id | No | 父目录ID,使用"0"表示根目录,默认为"0" | |
| description | No | 目录描述(可选) |
Implementation Reference
- src/index.ts:868-881 (registration)Registration of the 'apipost_create_folder' tool in the MCP server's ListTools handler, including its description and input schema.
{ name: 'apipost_create_folder', description: '创建API文档目录,支持在指定父目录下创建新的文件夹', inputSchema: { type: 'object', properties: { name: { type: 'string', description: '目录名称' }, parent_id: { type: 'string', description: '父目录ID,使用"0"表示根目录,默认为"0"' }, description: { type: 'string', description: '目录描述(可选)' } }, required: ['name'], additionalProperties: false } }, - src/index.ts:1254-1394 (handler)The execution handler for the 'apipost_create_folder' tool. Validates inputs, constructs a folder template object, performs security check, and creates the folder via API POST request to /open/apis/create endpoint.
case 'apipost_create_folder': if (!checkSecurityPermission('write')) { throw new Error(`🔒 安全模式 "${APIPOST_SECURITY_MODE}" 不允许创建操作。需要 "limited" 或 "full" 模式。`); } const folderName = args.name; const folderParentId = args.parent_id || '0'; const folderDescription = args.description || ''; if (!folderName) { throw new Error('请提供目录名称'); } // 生成目录模板 const folderTemplate = { project_id: currentWorkspace.projectId, target_id: generateId(), parent_id: folderParentId, target_type: 'folder', name: folderName, sort: 0, version: 0, server_id: '0', status: 1, is_changed: 1, is_create: 1, description: folderDescription, request: { header: { parameter: [] }, query: { parameter: [] }, body: { parameter: [] }, cookie: { parameter: [] }, auth: { type: 'inherit', kv: { key: '', value: '', in: 'header' }, bearer: { key: '' }, basic: { username: '', password: '' }, digest: { username: '', password: '', realm: '', nonce: '', algorithm: 'MD5', qop: '', nc: '', cnonce: '', opaque: '', disableRetryRequest: false }, oauth1: { consumerKey: '', consumerSecret: '', signatureMethod: 'HMAC-SHA1', addEmptyParamsToSign: true, includeBodyHash: true, addParamsToHeader: false, realm: '', version: '1.0', nonce: '', timestamp: '', verifier: '', callback: '', tokenSecret: '', token: '', disableHeaderEncoding: false }, hawk: { authId: '', authKey: '', algorithm: '', user: '', nonce: '', extraData: '', app: '', delegation: '', timestamp: '', includePayloadHash: false }, awsv4: { accessKey: '', secretKey: '', region: '', service: '', sessionToken: '', addAuthDataToQuery: false }, ntlm: { username: '', password: '', domain: '', workstation: '', disableRetryRequest: false }, edgegrid: { accessToken: '', clientToken: '', clientSecret: '', nonce: '', timestamp: '', baseURi: '', headersToSign: '' }, noauth: {}, jwt: { addTokenTo: 'header', algorithm: 'HS256', secret: '', isSecretBase64Encoded: false, payload: '', headerPrefix: 'Bearer', queryParamKey: 'token', header: '' }, asap: { alg: 'HS256', iss: '', aud: '', kid: '', privateKey: '', sub: '', claims: '', exp: '' } }, pre_tasks: [], post_tasks: [] }, is_force: -1, is_deleted: -1, is_conflicted: -1, mark_id: '1' }; // 创建目录 const createFolderResult = await apiClient.post('/open/apis/create', folderTemplate); if (createFolderResult.data.code !== 0) { throw new Error(`创建目录失败: ${createFolderResult.data.msg}`); } return { content: [{ type: 'text', text: `目录创建成功!\n名称: ${folderName}\n目录ID: ${folderTemplate.target_id}\n父目录ID: ${folderParentId}${folderDescription ? '\n描述: ' + folderDescription : ''}` }] };