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
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,15 @@ Docker-based workflows are retired. The provided `Dockerfile` now exits with a m

## 🛠️ Available MCP Tools

| Category | Tools |
| :------------ | :----------------------------------------------------------------------------------------------------------- |
| **Workouts** | `get-workouts`, `get-workout`, `create-workout`, `update-workout`, `get-workout-count`, `get-workout-events` |
| **Routines** | `get-routines`, `get-routine-by-id`, `create-routine`, `update-routine` |
| **Templates** | `get-exercise-templates`, `get-exercise-template`, `search-exercise-templates` |
| **Folders** | `get-routine-folders`, `get-routine-folder`, `create-routine-folder` |
| **Webhooks** | `get-webhook-subscription`, `create-webhook-subscription`, `delete-webhook-subscription` |
| Category | Tools |
| :-------------------- | :--------------------------------------------------------------------------------------------------------------------------------- |
| **Workouts** | `get-workouts`, `get-workout`, `create-workout`, `update-workout`, `get-workout-count`, `get-workout-events` |
| **Routines** | `get-routines`, `get-routine`, `create-routine`, `update-routine` |
| **Templates** | `get-exercise-templates`, `get-exercise-template`, `search-exercise-templates`, `create-exercise-template`, `get-exercise-history` |
| **Folders** | `get-routine-folders`, `get-routine-folder`, `create-routine-folder` |
| **Body Measurements** | `get-body-measurements`, `get-body-measurement`, `create-body-measurement`, `update-body-measurement` |
| **User** | `get-user-info` |
| **Webhooks** | `get-webhook-subscription`, `create-webhook-subscription`, `delete-webhook-subscription` |

---

Expand Down
48 changes: 41 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,7 @@
"commit": "commit"
},
"dependencies": {
"@kubb/cli": "^4.37.1",
"@kubb/core": "^4.37.1",
"@kubb/plugin-client": "^4.37.1",
"@kubb/plugin-faker": "^4.37.1",
"@kubb/plugin-oas": "^4.37.1",
"@kubb/plugin-ts": "^4.37.1",
"@kubb/plugin-zod": "^4.37.1",
"@modelcontextprotocol/sdk": "^1.29.0",
"@sentry/node": "^10.47.0",
"axios": "^1.14.0",
Expand All @@ -68,6 +62,12 @@
"@commitlint/cli": "^21.0.0",
"@commitlint/config-conventional": "^21.0.0",
"@commitlint/prompt-cli": "^21.0.0",
"@kubb/cli": "^4.37.1",
"@kubb/core": "^4.37.1",
"@kubb/plugin-faker": "^4.37.1",
"@kubb/plugin-oas": "^4.37.1",
"@kubb/plugin-ts": "^4.37.1",
"@kubb/plugin-zod": "^4.37.1",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/commit-analyzer": "^13.0.1",
"@semantic-release/git": "^10.0.1",
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import { registerBodyMeasurementTools } from "./tools/body-measurements.js";
import { registerFolderTools } from "./tools/folders.js";
import { registerRoutineTools } from "./tools/routines.js";
import { registerTemplateTools } from "./tools/templates.js";
import { registerUserTools } from "./tools/user.js";
import { registerWebhookTools } from "./tools/webhooks.js";
import { registerWorkoutTools } from "./tools/workouts.js";
import { assertApiKey, parseConfig } from "./utils/config.js";
Expand Down Expand Up @@ -77,6 +78,7 @@ function buildServer(apiKey: string) {
registerTemplateTools(server, hevyClient);
registerFolderTools(server, hevyClient);
registerBodyMeasurementTools(server, hevyClient);
registerUserTools(server, hevyClient);
registerWebhookTools(server, hevyClient);

return server;
Expand Down
122 changes: 122 additions & 0 deletions src/tools/annotations.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import type { ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
import { describe, expect, it, vi } from "vitest";
import { registerBodyMeasurementTools } from "./body-measurements.js";
import { registerFolderTools } from "./folders.js";
import { registerRoutineTools } from "./routines.js";
import { registerTemplateTools } from "./templates.js";
import { registerUserTools } from "./user.js";
import { registerWebhookTools } from "./webhooks.js";
import { registerWorkoutTools } from "./workouts.js";

const READ_ONLY_TOOLS = [
"get-workouts",
"get-workout",
"get-workout-count",
"get-workout-events",
"get-routines",
"get-routine",
"get-exercise-templates",
"get-exercise-template",
"get-exercise-history",
"search-exercise-templates",
"get-routine-folders",
"get-routine-folder",
"get-body-measurements",
"get-body-measurement",
"get-user-info",
"get-webhook-subscription",
] as const;

const CREATE_TOOLS = [
"create-workout",
"create-routine",
"create-exercise-template",
"create-routine-folder",
"create-body-measurement",
"create-webhook-subscription",
] as const;

const UPDATE_TOOLS = [
"update-workout",
"update-routine",
"update-body-measurement",
] as const;

const DESTRUCTIVE_TOOLS = ["delete-webhook-subscription"] as const;

function registerAllTools() {
const tool = vi.fn();
const server = { tool } as unknown as McpServer;
registerWorkoutTools(server, null);
registerRoutineTools(server, null);
registerTemplateTools(server, null);
registerFolderTools(server, null);
registerBodyMeasurementTools(server, null);
registerUserTools(server, null);
registerWebhookTools(server, null);
return tool;
}

function getAnnotations(
toolSpy: ReturnType<typeof vi.fn>,
name: string,
): ToolAnnotations {
const match = toolSpy.mock.calls.find(([toolName]) => toolName === name);
if (!match) {
throw new Error(`Tool ${name} was not registered`);
}
// server.tool(name, description, schema, annotations, handler)
return match[3] as ToolAnnotations;
}

describe("tool annotations", () => {
const tool = registerAllTools();

it("registers all known tools", () => {
const byName = (a: string, b: string) => a.localeCompare(b);
const registered = (tool.mock.calls.map(([name]) => name) as string[]).sort(
byName,
);
const expected = [
...READ_ONLY_TOOLS,
...CREATE_TOOLS,
...UPDATE_TOOLS,
...DESTRUCTIVE_TOOLS,
].sort(byName);
expect(registered).toEqual(expected);
});

it("every tool has a title and closed-world hint", () => {
for (const [name] of tool.mock.calls) {
const annotations = getAnnotations(tool, name as string);
expect(annotations.title, `${name} title`).toBeTruthy();
expect(annotations.openWorldHint, `${name} openWorldHint`).toBe(false);
}
});

it.each(READ_ONLY_TOOLS)("%s is read-only", (name) => {
const annotations = getAnnotations(tool, name);
expect(annotations.readOnlyHint).toBe(true);
});

it.each(CREATE_TOOLS)(
"%s is a non-destructive, non-idempotent write",
(name) => {
const annotations = getAnnotations(tool, name);
expect(annotations.readOnlyHint).toBe(false);
expect(annotations.destructiveHint).toBe(false);
expect(annotations.idempotentHint).toBe(false);
},
);

it.each([...UPDATE_TOOLS, ...DESTRUCTIVE_TOOLS])(
"%s is a destructive, idempotent write",
(name) => {
const annotations = getAnnotations(tool, name);
expect(annotations.readOnlyHint).toBe(false);
expect(annotations.destructiveHint).toBe(true);
expect(annotations.idempotentHint).toBe(true);
},
);
});
Loading
Loading