Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/tool-annotations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@taskade/mcp-server': patch
'@taskade/mcp-openapi-codegen': patch
---

Add MCP tool annotations to every generated tool: a human-friendly `title`
(from the humanized action map) plus `readOnlyHint`/`destructiveHint` derived
from each operation's HTTP method (GET/HEAD → read-only, DELETE → destructive).
Improves client UX/safety display and is a prerequisite for connector directories.
29 changes: 16 additions & 13 deletions packages/openapi-codegen/src/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,25 @@ export const codegen = async (opts: CodegenOpts) => {
return;
}

const annotations: Record<string, any> = {};

if (opts.actions?.[tool.name]) {
annotations.title = opts.actions[tool.name].title;
annotations.description = opts.actions[tool.name].description;
// Derive MCP tool annotations from the HTTP method: GET/HEAD are read-only,
// DELETE is destructive. A human-friendly title can be supplied via opts.actions.
const method = tool.method.toUpperCase();
const annotations: Record<string, any> = {
readOnlyHint: method === 'GET' || method === 'HEAD',
destructiveHint: method === 'DELETE',
};

const actionTitle = opts.actions?.[tool.name]?.title;
if (actionTitle) {
annotations.title = actionTitle;
}

const toolArgs = [
`"${tool.name}"`,
`"${tool.description}"`,
generateToolInputFromParsedTool(tool),
];
const description = opts.actions?.[tool.name]?.description ?? tool.description;

if (Object.keys(annotations).length > 0) {
toolArgs.push(JSON.stringify(annotations));
}
const toolArgs = [`"${tool.name}"`, `"${description}"`, generateToolInputFromParsedTool(tool)];

Comment on lines +89 to +92
// annotations always carry read-only/destructive hints, so always include them
toolArgs.push(JSON.stringify(annotations));

toolArgs.push(`async (args) => {
return await config.executeToolCall({
Expand Down
9 changes: 8 additions & 1 deletion packages/server/scripts/gen-taskade-mcp-tools.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import { dereference } from '@readme/openapi-parser';
import { codegen } from '@taskade/mcp-openapi-codegen';

import { ENABLED_TASKADE_ACTIONS } from '../src/constants';
import { ENABLED_TASKADE_ACTIONS, HUMANIZED_TASKADE_ACTIONS } from '../src/constants';

const document = await dereference('taskade-public.yaml');

// Supply a human-friendly title per tool from the humanized action map; the
// codegen derives readOnly/destructive hints from each operation's HTTP method.
const actions = Object.fromEntries(
Object.entries(HUMANIZED_TASKADE_ACTIONS).map(([name, title]) => [name, { title }]),
);
Comment on lines +8 to +12

await codegen({
path: 'src/tools.generated.ts',
document,
isActionsEnabled: ENABLED_TASKADE_ACTIONS,
actions,
});
Loading