@victox/hello-stdio 0.1.1 → 0.1.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/LICENSE +21 -0
- package/README.md +93 -0
- package/dist/cli.mjs +1 -3
- package/dist/index.mjs +2 -59
- package/package.json +21 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 victox
|
|
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/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# @victox/hello-stdio
|
|
2
|
+
|
|
3
|
+
An MCP server (stdio) that exposes two demo tools:
|
|
4
|
+
|
|
5
|
+
- `hello1`: generate a random greeting
|
|
6
|
+
- `hello2`: generate a greeting for a given name
|
|
7
|
+
|
|
8
|
+
## Requirements
|
|
9
|
+
|
|
10
|
+
- Node.js >= 18
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
### Global (recommended)
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm i -g @victox/hello-stdio
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Project-local
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm i @victox/hello-stdio
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Run
|
|
27
|
+
|
|
28
|
+
### If installed globally
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
hello-mcp-server
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### If installed locally
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npx -y @victox/hello-stdio hello-mcp-server
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
This is a **stdio** MCP server: it communicates via stdin/stdout and is meant to be launched by an MCP host.
|
|
41
|
+
|
|
42
|
+
## Use with OpenCode
|
|
43
|
+
|
|
44
|
+
Add to `.opencode/opencode.json`:
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"$schema": "https://opencode.ai/config.json",
|
|
49
|
+
"mcp": {
|
|
50
|
+
"hello-stdio": {
|
|
51
|
+
"type": "stdio",
|
|
52
|
+
"command": "hello-mcp-server",
|
|
53
|
+
"args": [],
|
|
54
|
+
"enabled": true
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
If you did not install globally, use `npx` instead:
|
|
61
|
+
|
|
62
|
+
```json
|
|
63
|
+
{
|
|
64
|
+
"mcp": {
|
|
65
|
+
"hello-stdio": {
|
|
66
|
+
"type": "stdio",
|
|
67
|
+
"command": "npx",
|
|
68
|
+
"args": ["-y", "@victox/hello-stdio", "hello-mcp-server"],
|
|
69
|
+
"enabled": true
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Tool API
|
|
76
|
+
|
|
77
|
+
### `hello1`
|
|
78
|
+
|
|
79
|
+
- input: none
|
|
80
|
+
- output: text greeting
|
|
81
|
+
|
|
82
|
+
### `hello2`
|
|
83
|
+
|
|
84
|
+
- input:
|
|
85
|
+
- `name` (string, required, non-empty)
|
|
86
|
+
- output: text greeting with `name`
|
|
87
|
+
|
|
88
|
+
## Troubleshooting
|
|
89
|
+
|
|
90
|
+
- If publish/install works but the host can't start the server, verify the executable exists:
|
|
91
|
+
- global: `which hello-mcp-server`
|
|
92
|
+
- local: `npx -y @victox/hello-stdio hello-mcp-server`
|
|
93
|
+
- If your host doesn't support stdio MCP servers, use the HTTP/SSE server packages instead.
|
package/dist/cli.mjs
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,59 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
-
|
|
5
|
-
//#region ../hello-lib/dist/index.js
|
|
6
|
-
const GREETINGS = [
|
|
7
|
-
"Hello!",
|
|
8
|
-
"Hi there!",
|
|
9
|
-
"Hey!",
|
|
10
|
-
"Howdy!",
|
|
11
|
-
"Good day!",
|
|
12
|
-
"Greetings!"
|
|
13
|
-
];
|
|
14
|
-
function pickRandom(items) {
|
|
15
|
-
if (items.length === 0) throw new Error("pickRandom: empty list");
|
|
16
|
-
return items[Math.floor(Math.random() * items.length)];
|
|
17
|
-
}
|
|
18
|
-
function registerHelloTools(server) {
|
|
19
|
-
server.registerTool("hello1", { description: "Generate a random greeting." }, async () => {
|
|
20
|
-
return { content: [{
|
|
21
|
-
type: "text",
|
|
22
|
-
text: pickRandom(GREETINGS)
|
|
23
|
-
}] };
|
|
24
|
-
});
|
|
25
|
-
server.registerTool("hello2", {
|
|
26
|
-
description: "Generate a greeting addressed to a provided name.",
|
|
27
|
-
inputSchema: { name: z.string().min(1).describe("Name to greet.") }
|
|
28
|
-
}, async ({ name }) => {
|
|
29
|
-
return { content: [{
|
|
30
|
-
type: "text",
|
|
31
|
-
text: `${pickRandom(GREETINGS)} ${name}`
|
|
32
|
-
}] };
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
function createHelloServer(info, options) {
|
|
36
|
-
const server = new McpServer(info, options);
|
|
37
|
-
registerHelloTools(server);
|
|
38
|
-
return server;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
//#endregion
|
|
42
|
-
//#region src/index.ts
|
|
43
|
-
async function main() {
|
|
44
|
-
const mcpServer = createHelloServer({
|
|
45
|
-
name: "hello-mcp-server",
|
|
46
|
-
version: "0.1.0"
|
|
47
|
-
});
|
|
48
|
-
const transport = new StdioServerTransport();
|
|
49
|
-
await mcpServer.connect(transport);
|
|
50
|
-
}
|
|
51
|
-
if (process.stdin.isTTY) process.stdin.resume();
|
|
52
|
-
main().catch((err) => {
|
|
53
|
-
const message = err instanceof Error ? err.stack ?? err.message : String(err);
|
|
54
|
-
process.stderr.write(message + "\n");
|
|
55
|
-
process.exit(1);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
//#endregion
|
|
59
|
-
export { };
|
|
1
|
+
import{McpServer as e}from"@modelcontextprotocol/sdk/server/mcp.js";import*as t from"zod/v4";import{StdioServerTransport as n}from"@modelcontextprotocol/sdk/server/stdio.js";const r=[`Hello!`,`Hi there!`,`Hey!`,`Howdy!`,`Good day!`,`Greetings!`];function i(e){if(e.length===0)throw Error(`pickRandom: empty list`);return e[Math.floor(Math.random()*e.length)]}function a(e){e.registerTool(`hello1`,{description:`Generate a random greeting.`},async()=>({content:[{type:`text`,text:i(r)}]})),e.registerTool(`hello2`,{description:`Generate a greeting addressed to a provided name.`,inputSchema:{name:t.string().min(1).describe(`Name to greet.`)}},async({name:e})=>({content:[{type:`text`,text:`${i(r)} ${e}`}]}))}function o(t,n){let r=new e(t,n);return a(r),r}async function s(){let e=o({name:`hello-mcp-server`,version:`0.1.0`}),t=new n;await e.connect(t)}process.stdin.isTTY&&process.stdin.resume(),s().catch(e=>{let t=e instanceof Error?e.stack??e.message:String(e);process.stderr.write(t+`
|
|
2
|
+
`),process.exit(1)});export{};
|
package/package.json
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@victox/hello-stdio",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"private": false,
|
|
5
|
+
"description": "MCP stdio server exposing hello1/hello2 demo tools",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"mcp",
|
|
9
|
+
"modelcontextprotocol",
|
|
10
|
+
"opencode",
|
|
11
|
+
"stdio",
|
|
12
|
+
"agent",
|
|
13
|
+
"tools"
|
|
14
|
+
],
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=18"
|
|
17
|
+
},
|
|
5
18
|
"type": "module",
|
|
6
19
|
"main": "dist/index.mjs",
|
|
7
20
|
"types": "dist/index.d.mts",
|
|
@@ -9,17 +22,22 @@
|
|
|
9
22
|
"hello-mcp-server": "dist/cli.mjs"
|
|
10
23
|
},
|
|
11
24
|
"files": [
|
|
12
|
-
"dist"
|
|
25
|
+
"dist",
|
|
26
|
+
"README.md",
|
|
27
|
+
"LICENSE"
|
|
13
28
|
],
|
|
14
29
|
"exports": {
|
|
15
30
|
".": "./dist/index.mjs",
|
|
16
31
|
"./cli": "./dist/cli.mjs",
|
|
17
32
|
"./package.json": "./package.json"
|
|
18
33
|
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
19
37
|
"scripts": {
|
|
20
38
|
"build": "tsdown",
|
|
21
39
|
"prepack": "pnpm run build",
|
|
22
|
-
"start": "node dist/index.
|
|
40
|
+
"start": "node dist/index.mjs"
|
|
23
41
|
},
|
|
24
42
|
"dependencies": {
|
|
25
43
|
"@modelcontextprotocol/sdk": "^1.0.0",
|