一键导入
add-tool
Add a new MCP tool (or extend an existing one) in the cognigy-mcp server
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Add a new MCP tool (or extend an existing one) in the cognigy-mcp server
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | add-tool |
| description | Add a new MCP tool (or extend an existing one) in the cognigy-mcp server |
Add a new MCP tool (or extend an existing one) in the cognigy-mcp server. The user will describe the tool's purpose, operations, and Cognigy API endpoints it should call.
This is a TypeScript MCP server. Tools follow a strict pattern across these files:
| File | Role |
|---|---|
src/tools/definitions.ts | Tool metadata: name, description, annotations, inputSchema (JSON Schema) |
src/schemas/tools.ts | Zod validation schemas — one per tool or discriminated union per multi-op tool |
src/tools/handlers.ts | ToolHandlers class — one handleXxx(args) method per tool + a case in handleToolCall() |
src/index.ts | Resource map (RESOURCE_MAP) — register any new guide here |
src/resources/<name>.md | Markdown guide for the tool (referenced via cognigy://guide/<name>) |
manifest.json | Marketplace entry — add { name, description } to the tools array |
src/__tests__/schemas.test.ts | Schema validation tests |
src/__tests__/tools.test.ts | Handler tests with mocked CognigyApiClient |
This server deliberately uses few tools (~13) to cover many Cognigy API endpoints (~115). Each tool groups related endpoints under a single operation parameter that acts as a router.
Example: manage_knowledge — one tool covers ~8 endpoints:
create_store → POST /v2.0/knowledgestorescreate_source → POST /v2.0/knowledgestores/{id}/sourceslist_sources → GET /v2.0/knowledgestores/{id}/sourcesingest_source → POST /v2.0/knowledgestores/{id}/sources/{id}/ingestlist_chunks → GET /v2.0/knowledgestores/{id}/chunksWhy this pattern:
projectId) and the description explains the full workflow across operations in one place.When to create a new tool vs. add an operation to an existing tool:
Reference templates are bundled with this skill. Use them as starting points:
${CLAUDE_SKILL_DIR}/templates/definition.ts — Tool definition entry for src/tools/definitions.ts${CLAUDE_SKILL_DIR}/templates/schema.ts — Zod schema for src/schemas/tools.ts${CLAUDE_SKILL_DIR}/templates/handler.ts — Handler method for src/tools/handlers.ts${CLAUDE_SKILL_DIR}/templates/manifest-entry.json — Manifest entry for manifest.json${CLAUDE_SKILL_DIR}/templates/resource-map-entry.ts — Resource map entry for src/index.tsRead these templates before writing code to match the exact conventions.
Before writing code, confirm with the user:
manage_packages)src/tools/definitions.ts and src/schemas/tools.ts to match conventionssrc/tools/definitions.ts)Read ${CLAUDE_SKILL_DIR}/templates/definition.ts for the template.
Add an entry to the tools array. Conventions:
BEFORE USING: Read cognigy://guide/<name> if a guide existssrc/schemas/tools.ts)Read ${CLAUDE_SKILL_DIR}/templates/schema.ts for the template.
z.object()z.discriminatedUnion("operation", [...])idSchema is already defined: z.string().regex(/^[a-f0-9]{24}$/)src/tools/handlers.ts)Read ${CLAUDE_SKILL_DIR}/templates/handler.ts for the template.
Add a method to the ToolHandlers class, then add the dispatch case in handleToolCall().
Key patterns:
this.apiClient.get/post/patch/delete/put/uploadFile for API callsfilterResponse(resourceType, result) to return summary viewswithHints(data, { action: "helpful suggestion" }) for actionable errorssrc/tools/ (e.g. packageImport.ts)Create src/resources/<tool-name>.md with usage documentation.
Read ${CLAUDE_SKILL_DIR}/templates/resource-map-entry.ts for the template. Add to RESOURCE_MAP in src/index.ts.
manifest.json)Read ${CLAUDE_SKILL_DIR}/templates/manifest-entry.json for the template. Add to the tools array.
Schema tests in src/__tests__/schemas.test.ts:
Handler tests in src/__tests__/tools.test.ts:
CognigyApiClient methods (jest.fn())describe/it blocksRun in order:
npx tsc -p tsconfig.json --noEmit — type checknpm test -- --runInBand — all tests passnpx prettier --write <changed-files> — format only the files you created or modifiedidSchema (24-char hex)handle<PascalCaseName> (e.g. handleManagePackages)this.apiClient.uploadFile() — see manage_packages handler for the patternREADME.md tool count and table if adding a brand new tool