@achmadya-dev/mcp-core 0.3.0 → 0.3.3
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/README.md +72 -17
- package/package.json +9 -11
package/README.md
CHANGED
|
@@ -2,23 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
Shared MCP SDK wrapper for `@achmadya-dev` servers: stdio transport, tool registration, JSON-safe responses, and env helpers.
|
|
4
4
|
|
|
5
|
-
Built on **MCP TypeScript SDK v2** (`@modelcontextprotocol/server`). Tool schemas use [Standard Schema](https://standardschema.dev/) —
|
|
5
|
+
Built on **MCP TypeScript SDK v2** (`@modelcontextprotocol/server`). Tool schemas use [Standard Schema](https://standardschema.dev/) — pick any compatible library in your package.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
pnpm add @achmadya-dev/mcp-core
|
|
10
|
+
pnpm add @achmadya-dev/mcp-core
|
|
11
|
+
# plus a Standard Schema library in your MCP package, e.g. zod, valibot, arktype, …
|
|
11
12
|
```
|
|
12
13
|
|
|
13
14
|
Installed automatically as a dependency of `@achmadya-dev/mcp-*-query` servers.
|
|
14
15
|
|
|
15
16
|
## Usage
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
Pass a Standard Schema object to `inputSchema` / `outputSchema`. Examples below use the same tool shape; only the schema library differs.
|
|
19
|
+
|
|
20
|
+
### Zod
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pnpm add zod
|
|
24
|
+
```
|
|
18
25
|
|
|
19
26
|
```typescript
|
|
20
27
|
import * as z from "zod";
|
|
21
|
-
import { defineTool, startMcpServer
|
|
28
|
+
import { defineTool, startMcpServer } from "@achmadya-dev/mcp-core";
|
|
22
29
|
|
|
23
30
|
const myTool = defineTool({
|
|
24
31
|
name: "my_tool",
|
|
@@ -26,30 +33,78 @@ const myTool = defineTool({
|
|
|
26
33
|
inputSchema: z.object({
|
|
27
34
|
name: z.string().describe("Item name"),
|
|
28
35
|
}),
|
|
29
|
-
outputSchema: z.object({
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
outputSchema: z.object({ ok: z.boolean() }),
|
|
37
|
+
handler: async ({ name }) => ({ ok: true }),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
await startMcpServer({ name: "My MCP", version: "1.0.0", tools: [myTool] });
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Valibot
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pnpm add valibot @valibot/to-json-schema
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import * as v from "valibot";
|
|
51
|
+
import { toStandardJsonSchema } from "@valibot/to-json-schema";
|
|
52
|
+
import { defineTool, startMcpServer } from "@achmadya-dev/mcp-core";
|
|
53
|
+
|
|
54
|
+
const myTool = defineTool({
|
|
55
|
+
name: "my_tool",
|
|
56
|
+
description: "Does something",
|
|
57
|
+
inputSchema: toStandardJsonSchema(
|
|
58
|
+
v.object({ name: v.pipe(v.string(), v.description("Item name")) })
|
|
59
|
+
),
|
|
60
|
+
outputSchema: toStandardJsonSchema(v.object({ ok: v.boolean() })),
|
|
32
61
|
handler: async ({ name }) => ({ ok: true }),
|
|
33
62
|
});
|
|
34
63
|
|
|
35
|
-
await startMcpServer({
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
64
|
+
await startMcpServer({ name: "My MCP", version: "1.0.0", tools: [myTool] });
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Other (ArkType, JSON Schema, …)
|
|
68
|
+
|
|
69
|
+
**ArkType** — Standard Schema native:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
pnpm add arktype
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
import { type } from "arktype";
|
|
77
|
+
import { defineTool, startMcpServer } from "@achmadya-dev/mcp-core";
|
|
78
|
+
|
|
79
|
+
defineTool({
|
|
80
|
+
name: "my_tool",
|
|
81
|
+
description: "Does something",
|
|
82
|
+
inputSchema: type({ name: "string" }),
|
|
83
|
+
outputSchema: type({ ok: "boolean" }),
|
|
84
|
+
handler: async ({ name }) => ({ ok: true }),
|
|
39
85
|
});
|
|
40
86
|
```
|
|
41
87
|
|
|
42
|
-
|
|
88
|
+
**Raw JSON Schema** — via MCP SDK adapter:
|
|
43
89
|
|
|
44
90
|
```typescript
|
|
91
|
+
import { fromJsonSchema } from "@modelcontextprotocol/server";
|
|
92
|
+
import { defineTool } from "@achmadya-dev/mcp-core";
|
|
93
|
+
|
|
45
94
|
defineTool({
|
|
46
|
-
name: "
|
|
47
|
-
description: "
|
|
48
|
-
inputSchema:
|
|
49
|
-
|
|
95
|
+
name: "my_tool",
|
|
96
|
+
description: "Does something",
|
|
97
|
+
inputSchema: fromJsonSchema({
|
|
98
|
+
type: "object",
|
|
99
|
+
properties: { name: { type: "string", description: "Item name" } },
|
|
100
|
+
required: ["name"],
|
|
101
|
+
}),
|
|
102
|
+
handler: async ({ name }) => ({ ok: true }),
|
|
50
103
|
});
|
|
51
104
|
```
|
|
52
105
|
|
|
106
|
+
Tools with no parameters: use an empty object schema from your library (e.g. `z.object({})`, `toStandardJsonSchema(v.object({}))`, `type({})`).
|
|
107
|
+
|
|
53
108
|
## Exports
|
|
54
109
|
|
|
55
110
|
- `Server`, `defineTool`, `ToolError`, `startMcpServer`
|
|
@@ -72,4 +127,4 @@ Uses [Changesets](https://github.com/changesets/changesets) — same flow as [`a
|
|
|
72
127
|
|
|
73
128
|
3. Merge that PR. Next push to `main` publishes to npm (`@achmadya-dev/mcp-core`).
|
|
74
129
|
|
|
75
|
-
**Remote prerequisites:** GitHub secret `NPM_TOKEN` (npm automation token with
|
|
130
|
+
**Remote prerequisites:** GitHub secret `NPM_TOKEN` (npm automation token with bypass 2FA for `@achmadya-dev`).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@achmadya-dev/mcp-core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Shared MCP server runtime, types, and env helpers for @achmadya-dev MCP packages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "achmadya",
|
|
@@ -28,18 +28,11 @@
|
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
|
-
"scripts": {
|
|
32
|
-
"build": "tsc -p tsconfig.build.json",
|
|
33
|
-
"prepare": "pnpm run build",
|
|
34
|
-
"prepublishOnly": "pnpm run build",
|
|
35
|
-
"changeset": "changeset",
|
|
36
|
-
"version-packages": "changeset version",
|
|
37
|
-
"publish-packages": "pnpm run build && changeset publish"
|
|
38
|
-
},
|
|
39
31
|
"engines": {
|
|
40
32
|
"node": ">=20"
|
|
41
33
|
},
|
|
42
34
|
"dependencies": {
|
|
35
|
+
"@cfworker/json-schema": "^4.1.1",
|
|
43
36
|
"@modelcontextprotocol/server": "2.0.0-alpha.2"
|
|
44
37
|
},
|
|
45
38
|
"devDependencies": {
|
|
@@ -47,5 +40,10 @@
|
|
|
47
40
|
"@types/node": "22.10.0",
|
|
48
41
|
"typescript": "5.7.2"
|
|
49
42
|
},
|
|
50
|
-
"
|
|
51
|
-
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsc -p tsconfig.build.json",
|
|
45
|
+
"changeset": "changeset",
|
|
46
|
+
"version-packages": "changeset version",
|
|
47
|
+
"publish-packages": "pnpm run build && changeset publish"
|
|
48
|
+
}
|
|
49
|
+
}
|