Custom tools should follow the same contract as built-in MCP servers: define a JSON-schema parameter contract, execute on the server, return structured JSON, and let the shared tool-call path handle allow-list checks, audit logging, timeouts, and ownership verification.
Keep authorization in TypeScript code. Tool descriptions help the model choose a tool, but they are not a security boundary.
Tool Definition Schema
Kommander tool definitions use a TypeScript interface equivalent to this shape:
Use short, factual descriptions. Avoid instructions such as “ignore previous messages” or text that looks like secrets. For customer-data connectors, OpenAPI descriptions are sanitized before exposure, but native tools should still be written as if the description will be visible to an untrusted model.
Minimal Server
Each server implements IMCPServer. The registry owns initialization, lookup, timeout wrapping, and result status normalization.
Registration
Register the server type once during MCP initialization, then return configs from environment or settings.
The type must match the registered server type. The id identifies the server instance cached for a user.
Customer-Data Connector Tools
For data that belongs to an authenticated end user, prefer an OpenAPI customer-data connector instead of a hand-written tool. The registry converts enabled OpenAPI operations into MCP tool definitions and records connector metadata with each call.
Result Ownership
When returning user-owned records, include at least one ownership marker such as userId, user_id, ownerId, endUserId, customerUserId, or the same fields nested under user, owner, endUser, customer, account, or profile.
The marker must match one of the verified identity values. If a mismatch is detected, the tool result becomes an empty successful object or array and an ownership failure audit event is written. The implementation guidance is maintained in docs/mcp-tool-ownership.md.
Authoring Checklist
- Use unique, stable tool names.
- Keep descriptions factual and free of instructions.
- Define complete JSON schemas with
requiredfields. - Validate arguments inside
executeToolbefore calling external systems. - Require
context.verifiedUserfor user-owned data. - Return structured JSON rather than prose.
- Include ownership markers on user-owned records.
- Configure
sensitiveFieldsfor connector-specific secrets or PII that audit logs must redact. - Keep external calls bounded by timeouts and response-size limits.