@almostjacked/hevy-mcp 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/main.js +12 -0
- package/dist/server.js +9 -0
- package/dist/version.js +2 -0
- package/dist/worker.js +37 -0
- package/package.json +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AJ Wallace
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/main.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
+
import { buildServer } from "./server.js";
|
|
4
|
+
const apiKey = process.env.HEVY_API_KEY;
|
|
5
|
+
if (!apiKey) {
|
|
6
|
+
console.error("hevy-mcp: missing HEVY_API_KEY environment variable.\n" +
|
|
7
|
+
"Get your key at https://hevy.com/settings?developer (Hevy PRO required), then e.g.:\n" +
|
|
8
|
+
' claude mcp add hevy -e HEVY_API_KEY=<key> -- npx -y @almostjacked/hevy-mcp');
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
11
|
+
const server = buildServer(apiKey, "Check the HEVY_API_KEY environment variable this server was started with.");
|
|
12
|
+
await server.connect(new StdioServerTransport());
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { createHevyClient, registerTools } from "@almostjacked/hevy-mcp-core";
|
|
3
|
+
import { VERSION } from "./version.js";
|
|
4
|
+
/** Build a fully-registered server for one Hevy API key (no transport attached). */
|
|
5
|
+
export function buildServer(apiKey, keyInvalidHint) {
|
|
6
|
+
const server = new McpServer({ name: "hevy-mcp", version: VERSION });
|
|
7
|
+
registerTools(server, createHevyClient(apiKey), { keyInvalidHint });
|
|
8
|
+
return server;
|
|
9
|
+
}
|
package/dist/version.js
ADDED
package/dist/worker.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
import { StreamableHTTPTransport } from "@hono/mcp";
|
|
3
|
+
import { buildServer } from "./server.js";
|
|
4
|
+
/** Constant-time-ish token check: compare SHA-256 digests, not raw strings. */
|
|
5
|
+
async function tokenMatches(given, expected) {
|
|
6
|
+
const enc = new TextEncoder();
|
|
7
|
+
const [a, b] = await Promise.all([
|
|
8
|
+
crypto.subtle.digest("SHA-256", enc.encode(given)),
|
|
9
|
+
crypto.subtle.digest("SHA-256", enc.encode(expected)),
|
|
10
|
+
]);
|
|
11
|
+
const av = new Uint8Array(a);
|
|
12
|
+
const bv = new Uint8Array(b);
|
|
13
|
+
let diff = 0;
|
|
14
|
+
for (let i = 0; i < av.length; i++)
|
|
15
|
+
diff |= av[i] ^ bv[i];
|
|
16
|
+
return diff === 0;
|
|
17
|
+
}
|
|
18
|
+
const app = new Hono();
|
|
19
|
+
app.get("/health", (c) => c.json({ ok: true }));
|
|
20
|
+
app.post("/mcp", async (c) => {
|
|
21
|
+
const auth = c.req.header("authorization") ?? "";
|
|
22
|
+
const token = auth.startsWith("Bearer ") ? auth.slice(7) : "";
|
|
23
|
+
if (!c.env.AUTH_TOKEN || !token || !(await tokenMatches(token, c.env.AUTH_TOKEN))) {
|
|
24
|
+
return c.json({ error: "unauthorized: send Authorization: Bearer <AUTH_TOKEN>" }, 401);
|
|
25
|
+
}
|
|
26
|
+
const server = buildServer(c.env.HEVY_API_KEY, "This self-hosted server's HEVY_API_KEY secret needs updating (wrangler secret put HEVY_API_KEY).");
|
|
27
|
+
const transport = new StreamableHTTPTransport();
|
|
28
|
+
await server.connect(transport);
|
|
29
|
+
// Stateless per-request server; the transport aborts its stream when the
|
|
30
|
+
// response completes and nothing else holds resources — no explicit close.
|
|
31
|
+
return transport.handleRequest(c);
|
|
32
|
+
});
|
|
33
|
+
app.on(["GET", "DELETE"], "/mcp", (c) => {
|
|
34
|
+
c.header("Allow", "POST");
|
|
35
|
+
return c.json({ error: "method not allowed: stateless server, POST only" }, 405);
|
|
36
|
+
});
|
|
37
|
+
export default app;
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@almostjacked/hevy-mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Unofficial MCP server for Hevy — stdio + self-host worker. Bring your own Hevy PRO API key.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"hevy-mcp": "dist/main.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@hono/mcp": "^0.3.1",
|
|
14
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
15
|
+
"hono": "^4.12.31",
|
|
16
|
+
"zod": "^4.4.3",
|
|
17
|
+
"@almostjacked/hevy-mcp-core": "0.1.0"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@anthropic-ai/mcpb": "^2.1.2",
|
|
21
|
+
"@types/node": "^22.0.0",
|
|
22
|
+
"esbuild": "^0.28.1",
|
|
23
|
+
"typescript": "^5.5.0",
|
|
24
|
+
"vitest": "^2.0.0",
|
|
25
|
+
"wrangler": "^4.114.0"
|
|
26
|
+
},
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=18"
|
|
29
|
+
},
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"author": "AJ Wallace <ajwallacemusic@gmail.com>",
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/almostjacked/hevy-mcp.git",
|
|
35
|
+
"directory": "apps/mcp"
|
|
36
|
+
},
|
|
37
|
+
"mcpName": "io.github.almostjacked/hevy-mcp",
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "node scripts/sync-versions.mjs && tsc -p tsconfig.json",
|
|
40
|
+
"start": "node dist/main.js",
|
|
41
|
+
"test": "vitest run",
|
|
42
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
43
|
+
"deploy": "wrangler deploy",
|
|
44
|
+
"build:mcpb": "node scripts/sync-versions.mjs && esbuild src/main.ts --bundle --platform=node --format=esm --outfile=mcpb/server/index.js --banner:js=\"import { createRequire } from 'module'; const require = createRequire(import.meta.url);\" && mcpb pack mcpb hevy-mcp.mcpb"
|
|
45
|
+
}
|
|
46
|
+
}
|