tiny-stdio-mcp-server 0.1.13 → 0.1.14
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 +33 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ npm install tiny-stdio-mcp-server
|
|
|
14
14
|
import { createServer, defineSchema } from "tiny-stdio-mcp-server";
|
|
15
15
|
|
|
16
16
|
const schema = defineSchema({
|
|
17
|
-
text: { type: "string", description: "Text to reverse" }
|
|
17
|
+
text: { type: "string", description: "Text to reverse" }
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
createServer({ name: "my-server", version: "1.0.0" })
|
|
@@ -49,7 +49,7 @@ Register a tool. The handler receives typed args matching the schema and returns
|
|
|
49
49
|
```ts
|
|
50
50
|
const schema = defineSchema({
|
|
51
51
|
query: { type: "string", description: "Search query" },
|
|
52
|
-
limit: { type: "number", description: "Max results", optional: true }
|
|
52
|
+
limit: { type: "number", description: "Max results", optional: true }
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
server.tool("search", "Search for things", schema, async ({ query, limit }) => {
|
|
@@ -62,7 +62,7 @@ For structured-data tools, pass a root-object output schema. The server advertis
|
|
|
62
62
|
|
|
63
63
|
```ts
|
|
64
64
|
const input = defineSchema({
|
|
65
|
-
query: { type: "string" }
|
|
65
|
+
query: { type: "string" }
|
|
66
66
|
});
|
|
67
67
|
const output = defineSchema({
|
|
68
68
|
items: {
|
|
@@ -71,16 +71,22 @@ const output = defineSchema({
|
|
|
71
71
|
type: "object",
|
|
72
72
|
properties: {
|
|
73
73
|
title: { type: "string" },
|
|
74
|
-
score: { type: "number" }
|
|
74
|
+
score: { type: "number" }
|
|
75
75
|
},
|
|
76
|
-
required: ["title", "score"]
|
|
77
|
-
}
|
|
78
|
-
}
|
|
76
|
+
required: ["title", "score"]
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
79
|
});
|
|
80
80
|
|
|
81
|
-
server.tool(
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
server.tool(
|
|
82
|
+
"search",
|
|
83
|
+
"Search",
|
|
84
|
+
input,
|
|
85
|
+
async ({ query }) => ({
|
|
86
|
+
items: [{ title: query, score: 1 }]
|
|
87
|
+
}),
|
|
88
|
+
output
|
|
89
|
+
);
|
|
84
90
|
```
|
|
85
91
|
|
|
86
92
|
Output schemas must have `type: "object"` at the root. Tools whose natural result is prose, images, audio, files, or other content blocks should omit `outputSchema` and keep returning content.
|
|
@@ -113,6 +119,12 @@ await server.connectSDK(sdkTransport);
|
|
|
113
119
|
|
|
114
120
|
Dynamically add/remove tools at runtime and notify connected clients.
|
|
115
121
|
|
|
122
|
+
## Configuration Options
|
|
123
|
+
|
|
124
|
+
- `createServer({ name, version })`: server identity sent during MCP initialization.
|
|
125
|
+
- `.tool(name, description, schema, handler, outputSchema?)`: tool metadata, input schema, handler, and optional structured output schema.
|
|
126
|
+
- `.connect({ readable, writable })`: custom stream transport for tests or embedded hosts.
|
|
127
|
+
|
|
116
128
|
## `defineSchema(definition)`
|
|
117
129
|
|
|
118
130
|
Type-safe schema builder. Returns a JSON Schema object with inferred TypeScript types.
|
|
@@ -120,11 +132,15 @@ Type-safe schema builder. Returns a JSON Schema object with inferred TypeScript
|
|
|
120
132
|
```ts
|
|
121
133
|
const schema = defineSchema({
|
|
122
134
|
name: { type: "string", description: "User name" },
|
|
123
|
-
age: { type: "number", description: "User age", optional: true }
|
|
135
|
+
age: { type: "number", description: "User age", optional: true }
|
|
124
136
|
});
|
|
125
137
|
// Handler receives: { name: string; age?: number }
|
|
126
138
|
```
|
|
127
139
|
|
|
140
|
+
## Environment Variables
|
|
141
|
+
|
|
142
|
+
This package does not read public environment variables.
|
|
143
|
+
|
|
128
144
|
Supported types: `string`, `number`, `boolean`, `object`, `array`.
|
|
129
145
|
|
|
130
146
|
## Content helpers
|
|
@@ -189,8 +205,12 @@ Use `createTestPair` with the official MCP SDK for in-memory testing:
|
|
|
189
205
|
```ts
|
|
190
206
|
import { createTestPair } from "tiny-stdio-mcp-server/testing";
|
|
191
207
|
|
|
192
|
-
const server = createServer({ name: "test", version: "1.0.0" })
|
|
193
|
-
|
|
208
|
+
const server = createServer({ name: "test", version: "1.0.0" }).tool(
|
|
209
|
+
"ping",
|
|
210
|
+
"Ping",
|
|
211
|
+
defineSchema({}),
|
|
212
|
+
() => "pong"
|
|
213
|
+
);
|
|
194
214
|
|
|
195
215
|
const { client, cleanup } = await createTestPair(server);
|
|
196
216
|
|