@achmadya-dev/mcp-core 0.3.0 → 0.3.1

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.
Files changed (2) hide show
  1. package/README.md +72 -17
  2. package/package.json +8 -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/) — Zod v4 works natively with MCP.
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 zod
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
- Zod v4 implements Standard Schema natively — pass `z.object(...)` directly to `inputSchema` / `outputSchema`:
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, envStr, type ToolDefinition } from "@achmadya-dev/mcp-core";
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
- ok: z.boolean(),
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
- name: "My MCP",
37
- version: "1.0.0",
38
- tools: [myTool],
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
- Tools with no parameters:
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: "ping",
47
- description: "Health check",
48
- inputSchema: z.object({}),
49
- handler: async () => ({ status: "ok" }),
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 publish access to `@achmadya-dev`).
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.0",
3
+ "version": "0.3.1",
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,14 +28,6 @@
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
  },
@@ -47,5 +39,10 @@
47
39
  "@types/node": "22.10.0",
48
40
  "typescript": "5.7.2"
49
41
  },
50
- "packageManager": "pnpm@10.33.0"
51
- }
42
+ "scripts": {
43
+ "build": "tsc -p tsconfig.build.json",
44
+ "changeset": "changeset",
45
+ "version-packages": "changeset version",
46
+ "publish-packages": "pnpm run build && changeset publish"
47
+ }
48
+ }