@cyanheads/calculator-mcp-server 0.1.14 → 0.1.15
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/AGENTS.md +28 -9
- package/CLAUDE.md +28 -9
- package/README.md +1 -1
- package/dist/mcp-server/resources/definitions/help.resource.d.ts +1 -1
- package/dist/mcp-server/resources/definitions/help.resource.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/calculate.tool.d.ts +1 -1
- package/dist/mcp-server/tools/definitions/calculate.tool.d.ts.map +1 -1
- package/package.json +2 -2
- package/server.json +3 -3
package/AGENTS.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Agent Protocol
|
|
2
2
|
|
|
3
3
|
**Server:** calculator-mcp-server
|
|
4
|
-
**Version:** 0.1.
|
|
4
|
+
**Version:** 0.1.15
|
|
5
5
|
**Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core)
|
|
6
6
|
|
|
7
7
|
> **Read the framework docs first:** `node_modules/@cyanheads/mcp-ts-core/CLAUDE.md` contains the full API reference — builders, Context, error codes, exports, patterns. This file covers server-specific conventions only.
|
|
@@ -158,24 +158,41 @@ Handlers receive a unified `ctx` object. Key properties:
|
|
|
158
158
|
|
|
159
159
|
## Errors
|
|
160
160
|
|
|
161
|
-
Handlers throw — the framework catches, classifies, and formats.
|
|
161
|
+
Handlers throw — the framework catches, classifies, and formats.
|
|
162
|
+
|
|
163
|
+
**Recommended: typed error contract.** Declare `errors: [{ reason, code, when, retryable? }]` on `tool()` / `resource()` to advertise the failure surface in `tools/list` (under `_meta['mcp-ts-core/errors']`) and receive a typed `ctx.fail(reason, …)` keyed by the declared reason union. TypeScript catches `ctx.fail('typo')` at compile time, `data.reason` is auto-populated for observability, and the linter enforces conformance against the handler body. Baseline codes (`InternalError`, `ServiceUnavailable`, `Timeout`, `ValidationError`, `SerializationError`) bubble freely and don't need declaring.
|
|
162
164
|
|
|
163
165
|
```ts
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
166
|
+
errors: [
|
|
167
|
+
{ reason: 'no_match', code: JsonRpcErrorCode.NotFound, when: 'No item matched the query' },
|
|
168
|
+
],
|
|
169
|
+
async handler(input, ctx) {
|
|
170
|
+
const item = await db.find(input.id);
|
|
171
|
+
if (!item) throw ctx.fail('no_match', `No item ${input.id}`);
|
|
172
|
+
return item;
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Fallback (no contract entry fits, prototype tools, service-layer code):** throw via factories or plain `Error`.
|
|
167
177
|
|
|
168
|
-
|
|
169
|
-
|
|
178
|
+
```ts
|
|
179
|
+
// Error factories — explicit code, concise
|
|
180
|
+
import { notFound, validationError, serviceUnavailable } from '@cyanheads/mcp-ts-core/errors';
|
|
170
181
|
throw notFound('Item not found', { itemId });
|
|
171
182
|
throw serviceUnavailable('API unavailable', { url }, { cause: err });
|
|
172
183
|
|
|
173
|
-
//
|
|
184
|
+
// Plain Error — framework auto-classifies from message patterns
|
|
185
|
+
throw new Error('Item not found'); // → NotFound
|
|
186
|
+
throw new Error('Invalid query format'); // → ValidationError
|
|
187
|
+
|
|
188
|
+
// McpError — when no factory exists for the code
|
|
174
189
|
import { McpError, JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
175
190
|
throw new McpError(JsonRpcErrorCode.DatabaseError, 'Connection failed', { pool: 'primary' });
|
|
176
191
|
```
|
|
177
192
|
|
|
178
|
-
|
|
193
|
+
Available factories: `invalidParams`, `invalidRequest`, `notFound`, `forbidden`, `unauthorized`, `validationError`, `conflict`, `rateLimited`, `timeout`, `serviceUnavailable`, `configurationError`, `internalError`, `serializationError`, `databaseError`. For HTTP responses from upstream APIs, use `httpErrorFromResponse(response, { service, data })` from `/utils`.
|
|
194
|
+
|
|
195
|
+
See framework CLAUDE.md and the `api-errors` skill for the full auto-classification table and contract reference.
|
|
179
196
|
|
|
180
197
|
---
|
|
181
198
|
|
|
@@ -225,6 +242,7 @@ Available skills:
|
|
|
225
242
|
| `setup` | Post-init project orientation |
|
|
226
243
|
| `design-mcp-server` | Design tool surface, resources, and services for a new server |
|
|
227
244
|
| `add-tool` | Scaffold a new tool definition |
|
|
245
|
+
| `add-app-tool` | Scaffold an MCP App tool + paired UI resource |
|
|
228
246
|
| `add-resource` | Scaffold a new resource definition |
|
|
229
247
|
| `add-prompt` | Scaffold a new prompt definition |
|
|
230
248
|
| `add-service` | Scaffold a new service integration |
|
|
@@ -322,6 +340,7 @@ import { getServerConfig } from '@/config/server-config.js';
|
|
|
322
340
|
## Checklist
|
|
323
341
|
|
|
324
342
|
- [ ] Zod schemas: all fields have `.describe()`, only JSON-Schema-serializable types (no `z.custom()`, `z.date()`, `z.transform()`, etc.)
|
|
343
|
+
- [ ] Optional nested objects: handler guards for empty inner values from form-based clients (`if (input.obj?.field && ...)`, not just `if (input.obj)`). When regex/length constraints matter, use `z.union([z.literal(''), z.string().regex(...).describe(...)])` — literal variants are exempt from `describe-on-fields`.
|
|
325
344
|
- [ ] JSDoc `@fileoverview` + `@module` on every file
|
|
326
345
|
- [ ] `ctx.log` for logging, `ctx.state` for storage
|
|
327
346
|
- [ ] Handlers throw on failure — error factories or plain `Error`, no try/catch
|
package/CLAUDE.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Agent Protocol
|
|
2
2
|
|
|
3
3
|
**Server:** calculator-mcp-server
|
|
4
|
-
**Version:** 0.1.
|
|
4
|
+
**Version:** 0.1.15
|
|
5
5
|
**Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core)
|
|
6
6
|
|
|
7
7
|
> **Read the framework docs first:** `node_modules/@cyanheads/mcp-ts-core/CLAUDE.md` contains the full API reference — builders, Context, error codes, exports, patterns. This file covers server-specific conventions only.
|
|
@@ -158,24 +158,41 @@ Handlers receive a unified `ctx` object. Key properties:
|
|
|
158
158
|
|
|
159
159
|
## Errors
|
|
160
160
|
|
|
161
|
-
Handlers throw — the framework catches, classifies, and formats.
|
|
161
|
+
Handlers throw — the framework catches, classifies, and formats.
|
|
162
|
+
|
|
163
|
+
**Recommended: typed error contract.** Declare `errors: [{ reason, code, when, retryable? }]` on `tool()` / `resource()` to advertise the failure surface in `tools/list` (under `_meta['mcp-ts-core/errors']`) and receive a typed `ctx.fail(reason, …)` keyed by the declared reason union. TypeScript catches `ctx.fail('typo')` at compile time, `data.reason` is auto-populated for observability, and the linter enforces conformance against the handler body. Baseline codes (`InternalError`, `ServiceUnavailable`, `Timeout`, `ValidationError`, `SerializationError`) bubble freely and don't need declaring.
|
|
162
164
|
|
|
163
165
|
```ts
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
166
|
+
errors: [
|
|
167
|
+
{ reason: 'no_match', code: JsonRpcErrorCode.NotFound, when: 'No item matched the query' },
|
|
168
|
+
],
|
|
169
|
+
async handler(input, ctx) {
|
|
170
|
+
const item = await db.find(input.id);
|
|
171
|
+
if (!item) throw ctx.fail('no_match', `No item ${input.id}`);
|
|
172
|
+
return item;
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Fallback (no contract entry fits, prototype tools, service-layer code):** throw via factories or plain `Error`.
|
|
167
177
|
|
|
168
|
-
|
|
169
|
-
|
|
178
|
+
```ts
|
|
179
|
+
// Error factories — explicit code, concise
|
|
180
|
+
import { notFound, validationError, serviceUnavailable } from '@cyanheads/mcp-ts-core/errors';
|
|
170
181
|
throw notFound('Item not found', { itemId });
|
|
171
182
|
throw serviceUnavailable('API unavailable', { url }, { cause: err });
|
|
172
183
|
|
|
173
|
-
//
|
|
184
|
+
// Plain Error — framework auto-classifies from message patterns
|
|
185
|
+
throw new Error('Item not found'); // → NotFound
|
|
186
|
+
throw new Error('Invalid query format'); // → ValidationError
|
|
187
|
+
|
|
188
|
+
// McpError — when no factory exists for the code
|
|
174
189
|
import { McpError, JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
175
190
|
throw new McpError(JsonRpcErrorCode.DatabaseError, 'Connection failed', { pool: 'primary' });
|
|
176
191
|
```
|
|
177
192
|
|
|
178
|
-
|
|
193
|
+
Available factories: `invalidParams`, `invalidRequest`, `notFound`, `forbidden`, `unauthorized`, `validationError`, `conflict`, `rateLimited`, `timeout`, `serviceUnavailable`, `configurationError`, `internalError`, `serializationError`, `databaseError`. For HTTP responses from upstream APIs, use `httpErrorFromResponse(response, { service, data })` from `/utils`.
|
|
194
|
+
|
|
195
|
+
See framework CLAUDE.md and the `api-errors` skill for the full auto-classification table and contract reference.
|
|
179
196
|
|
|
180
197
|
---
|
|
181
198
|
|
|
@@ -225,6 +242,7 @@ Available skills:
|
|
|
225
242
|
| `setup` | Post-init project orientation |
|
|
226
243
|
| `design-mcp-server` | Design tool surface, resources, and services for a new server |
|
|
227
244
|
| `add-tool` | Scaffold a new tool definition |
|
|
245
|
+
| `add-app-tool` | Scaffold an MCP App tool + paired UI resource |
|
|
228
246
|
| `add-resource` | Scaffold a new resource definition |
|
|
229
247
|
| `add-prompt` | Scaffold a new prompt definition |
|
|
230
248
|
| `add-service` | Scaffold a new service integration |
|
|
@@ -322,6 +340,7 @@ import { getServerConfig } from '@/config/server-config.js';
|
|
|
322
340
|
## Checklist
|
|
323
341
|
|
|
324
342
|
- [ ] Zod schemas: all fields have `.describe()`, only JSON-Schema-serializable types (no `z.custom()`, `z.date()`, `z.transform()`, etc.)
|
|
343
|
+
- [ ] Optional nested objects: handler guards for empty inner values from form-based clients (`if (input.obj?.field && ...)`, not just `if (input.obj)`). When regex/length constraints matter, use `z.union([z.literal(''), z.string().regex(...).describe(...)])` — literal variants are exempt from `describe-on-fields`.
|
|
325
344
|
- [ ] JSDoc `@fileoverview` + `@module` on every file
|
|
326
345
|
- [ ] `ctx.log` for logging, `ctx.state` for storage
|
|
327
346
|
- [ ] Handlers throw on failure — error factories or plain `Error`, no try/catch
|
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
[](https://www.npmjs.com/package/@cyanheads/calculator-mcp-server)
|
|
10
10
|
[](https://github.com/users/cyanheads/packages/container/package/calculator-mcp-server)
|
|
11
|
-
[](./CHANGELOG.md) [](https://www.npmjs.com/package/@cyanheads/mcp-ts-core)
|
|
12
12
|
|
|
13
13
|
[](https://modelcontextprotocol.io/) [](./LICENSE) [](https://www.typescriptlang.org/)
|
|
14
14
|
|
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export declare const helpResource: import("@cyanheads/mcp-ts-core").ResourceDefinition<import("zod").ZodObject<Readonly<{
|
|
6
6
|
[k: string]: import("zod/v4/core").$ZodType<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>;
|
|
7
|
-
}>, import("zod/v4/core").$strip>, undefined>;
|
|
7
|
+
}>, import("zod/v4/core").$strip>, undefined, undefined>;
|
|
8
8
|
//# sourceMappingURL=help.resource.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.resource.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/resources/definitions/help.resource.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,eAAO,MAAM,YAAY;;
|
|
1
|
+
{"version":3,"file":"help.resource.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/resources/definitions/help.resource.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,eAAO,MAAM,YAAY;;wDAOvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculate.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/calculate.tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAIjD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"calculate.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/calculate.tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAIjD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;6BA6FxB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cyanheads/calculator-mcp-server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
4
|
"description": "Calculator MCP server — evaluate, simplify, and differentiate math expressions.",
|
|
5
5
|
"mcpName": "io.github.cyanheads/calculator-mcp-server",
|
|
6
6
|
"type": "module",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"access": "public"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@cyanheads/mcp-ts-core": "^0.
|
|
68
|
+
"@cyanheads/mcp-ts-core": "^0.8.0",
|
|
69
69
|
"mathjs": "^15.2.0",
|
|
70
70
|
"pino-pretty": "^13.1.3"
|
|
71
71
|
},
|
package/server.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"url": "https://github.com/cyanheads/calculator-mcp-server",
|
|
7
7
|
"source": "github"
|
|
8
8
|
},
|
|
9
|
-
"version": "0.1.
|
|
9
|
+
"version": "0.1.15",
|
|
10
10
|
"remotes": [
|
|
11
11
|
{
|
|
12
12
|
"type": "streamable-http",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"registryBaseUrl": "https://registry.npmjs.org",
|
|
20
20
|
"identifier": "@cyanheads/calculator-mcp-server",
|
|
21
21
|
"runtimeHint": "bun",
|
|
22
|
-
"version": "0.1.
|
|
22
|
+
"version": "0.1.15",
|
|
23
23
|
"packageArguments": [
|
|
24
24
|
{
|
|
25
25
|
"type": "positional",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"registryBaseUrl": "https://registry.npmjs.org",
|
|
70
70
|
"identifier": "@cyanheads/calculator-mcp-server",
|
|
71
71
|
"runtimeHint": "bun",
|
|
72
|
-
"version": "0.1.
|
|
72
|
+
"version": "0.1.15",
|
|
73
73
|
"packageArguments": [
|
|
74
74
|
{
|
|
75
75
|
"type": "positional",
|