@lynq/lynq 0.6.0 → 0.7.0
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/package.json +186 -200
- package/README.md +0 -122
package/package.json
CHANGED
|
@@ -1,201 +1,187 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
},
|
|
189
|
-
"homepage": "https://github.com/hogekai/lynq#readme",
|
|
190
|
-
"license": "MIT",
|
|
191
|
-
"engines": {
|
|
192
|
-
"node": ">=18"
|
|
193
|
-
},
|
|
194
|
-
"packageManager": "pnpm@10.30.1",
|
|
195
|
-
"pnpm": {
|
|
196
|
-
"onlyBuiltDependencies": [
|
|
197
|
-
"@biomejs/biome",
|
|
198
|
-
"esbuild"
|
|
199
|
-
]
|
|
200
|
-
}
|
|
201
|
-
}
|
|
2
|
+
"name": "@lynq/lynq",
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"description": "Lightweight MCP server framework. Tool visibility control through middleware.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/index.mjs"
|
|
10
|
+
},
|
|
11
|
+
"./auth": {
|
|
12
|
+
"types": "./dist/middleware/auth.d.ts",
|
|
13
|
+
"import": "./dist/middleware/auth.mjs"
|
|
14
|
+
},
|
|
15
|
+
"./stdio": {
|
|
16
|
+
"types": "./dist/adapters/stdio.d.ts",
|
|
17
|
+
"import": "./dist/adapters/stdio.mjs"
|
|
18
|
+
},
|
|
19
|
+
"./hono": {
|
|
20
|
+
"types": "./dist/adapters/hono.d.ts",
|
|
21
|
+
"import": "./dist/adapters/hono.mjs"
|
|
22
|
+
},
|
|
23
|
+
"./express": {
|
|
24
|
+
"types": "./dist/adapters/express.d.ts",
|
|
25
|
+
"import": "./dist/adapters/express.mjs"
|
|
26
|
+
},
|
|
27
|
+
"./test": {
|
|
28
|
+
"types": "./dist/test.d.ts",
|
|
29
|
+
"import": "./dist/test.mjs"
|
|
30
|
+
},
|
|
31
|
+
"./guard": {
|
|
32
|
+
"types": "./dist/middleware/guard.d.ts",
|
|
33
|
+
"import": "./dist/middleware/guard.mjs"
|
|
34
|
+
},
|
|
35
|
+
"./logger": {
|
|
36
|
+
"types": "./dist/middleware/logger.d.ts",
|
|
37
|
+
"import": "./dist/middleware/logger.mjs"
|
|
38
|
+
},
|
|
39
|
+
"./rate-limit": {
|
|
40
|
+
"types": "./dist/middleware/rate-limit.d.ts",
|
|
41
|
+
"import": "./dist/middleware/rate-limit.mjs"
|
|
42
|
+
},
|
|
43
|
+
"./truncate": {
|
|
44
|
+
"types": "./dist/middleware/truncate.d.ts",
|
|
45
|
+
"import": "./dist/middleware/truncate.mjs"
|
|
46
|
+
},
|
|
47
|
+
"./combine": {
|
|
48
|
+
"types": "./dist/middleware/combine.d.ts",
|
|
49
|
+
"import": "./dist/middleware/combine.mjs"
|
|
50
|
+
},
|
|
51
|
+
"./credentials": {
|
|
52
|
+
"types": "./dist/middleware/credentials.d.ts",
|
|
53
|
+
"import": "./dist/middleware/credentials.mjs"
|
|
54
|
+
},
|
|
55
|
+
"./url-action": {
|
|
56
|
+
"types": "./dist/middleware/url-action.d.ts",
|
|
57
|
+
"import": "./dist/middleware/url-action.mjs"
|
|
58
|
+
},
|
|
59
|
+
"./oauth": {
|
|
60
|
+
"types": "./dist/middleware/oauth.d.ts",
|
|
61
|
+
"import": "./dist/middleware/oauth.mjs"
|
|
62
|
+
},
|
|
63
|
+
"./payment": {
|
|
64
|
+
"types": "./dist/middleware/payment.d.ts",
|
|
65
|
+
"import": "./dist/middleware/payment.mjs"
|
|
66
|
+
},
|
|
67
|
+
"./bearer": {
|
|
68
|
+
"types": "./dist/middleware/bearer.d.ts",
|
|
69
|
+
"import": "./dist/middleware/bearer.mjs"
|
|
70
|
+
},
|
|
71
|
+
"./jwt": {
|
|
72
|
+
"types": "./dist/middleware/jwt.d.ts",
|
|
73
|
+
"import": "./dist/middleware/jwt.mjs"
|
|
74
|
+
},
|
|
75
|
+
"./github": {
|
|
76
|
+
"types": "./dist/middleware/github.d.ts",
|
|
77
|
+
"import": "./dist/middleware/github.mjs"
|
|
78
|
+
},
|
|
79
|
+
"./github-oauth": {
|
|
80
|
+
"types": "./dist/middleware/github.d.ts",
|
|
81
|
+
"import": "./dist/middleware/github.mjs"
|
|
82
|
+
},
|
|
83
|
+
"./google": {
|
|
84
|
+
"types": "./dist/middleware/google.d.ts",
|
|
85
|
+
"import": "./dist/middleware/google.mjs"
|
|
86
|
+
},
|
|
87
|
+
"./google-oauth": {
|
|
88
|
+
"types": "./dist/middleware/google.d.ts",
|
|
89
|
+
"import": "./dist/middleware/google.mjs"
|
|
90
|
+
},
|
|
91
|
+
"./stripe": {
|
|
92
|
+
"types": "./dist/middleware/stripe.d.ts",
|
|
93
|
+
"import": "./dist/middleware/stripe.mjs"
|
|
94
|
+
},
|
|
95
|
+
"./crypto": {
|
|
96
|
+
"types": "./dist/middleware/crypto.d.ts",
|
|
97
|
+
"import": "./dist/middleware/crypto.mjs"
|
|
98
|
+
},
|
|
99
|
+
"./usdc": {
|
|
100
|
+
"types": "./dist/middleware/crypto.d.ts",
|
|
101
|
+
"import": "./dist/middleware/crypto.mjs"
|
|
102
|
+
},
|
|
103
|
+
"./tip": {
|
|
104
|
+
"types": "./dist/middleware/tip.d.ts",
|
|
105
|
+
"import": "./dist/middleware/tip.mjs"
|
|
106
|
+
},
|
|
107
|
+
"./store": {
|
|
108
|
+
"types": "./dist/store.d.ts",
|
|
109
|
+
"import": "./dist/store.mjs"
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
"files": [
|
|
113
|
+
"dist"
|
|
114
|
+
],
|
|
115
|
+
"sideEffects": false,
|
|
116
|
+
"dependencies": {
|
|
117
|
+
"@modelcontextprotocol/sdk": "^1.27.0"
|
|
118
|
+
},
|
|
119
|
+
"devDependencies": {
|
|
120
|
+
"@biomejs/biome": "^1.9.0",
|
|
121
|
+
"@types/express": "^5.0.6",
|
|
122
|
+
"express": "^5.2.1",
|
|
123
|
+
"hono": "^4.12.5",
|
|
124
|
+
"jose": "^6.2.1",
|
|
125
|
+
"stripe": "^20.4.1",
|
|
126
|
+
"tsup": "^8.0.0",
|
|
127
|
+
"typescript": "^5.6.0",
|
|
128
|
+
"vitest": "^2.0.0",
|
|
129
|
+
"zod": "^3.24.0"
|
|
130
|
+
},
|
|
131
|
+
"peerDependencies": {
|
|
132
|
+
"express": "^5.0.0",
|
|
133
|
+
"hono": "^4.0.0",
|
|
134
|
+
"jose": "^6.0.0",
|
|
135
|
+
"stripe": "^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0",
|
|
136
|
+
"zod": "^3.0.0"
|
|
137
|
+
},
|
|
138
|
+
"peerDependenciesMeta": {
|
|
139
|
+
"zod": {
|
|
140
|
+
"optional": true
|
|
141
|
+
},
|
|
142
|
+
"hono": {
|
|
143
|
+
"optional": true
|
|
144
|
+
},
|
|
145
|
+
"express": {
|
|
146
|
+
"optional": true
|
|
147
|
+
},
|
|
148
|
+
"jose": {
|
|
149
|
+
"optional": true
|
|
150
|
+
},
|
|
151
|
+
"stripe": {
|
|
152
|
+
"optional": true
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
"publishConfig": {
|
|
156
|
+
"access": "public"
|
|
157
|
+
},
|
|
158
|
+
"keywords": [
|
|
159
|
+
"mcp",
|
|
160
|
+
"model-context-protocol",
|
|
161
|
+
"framework",
|
|
162
|
+
"middleware",
|
|
163
|
+
"ai",
|
|
164
|
+
"agent"
|
|
165
|
+
],
|
|
166
|
+
"repository": {
|
|
167
|
+
"type": "git",
|
|
168
|
+
"url": "https://github.com/hogekai/lynq",
|
|
169
|
+
"directory": "packages/lynq"
|
|
170
|
+
},
|
|
171
|
+
"bugs": {
|
|
172
|
+
"url": "https://github.com/hogekai/lynq/issues"
|
|
173
|
+
},
|
|
174
|
+
"homepage": "https://github.com/hogekai/lynq#readme",
|
|
175
|
+
"license": "MIT",
|
|
176
|
+
"engines": {
|
|
177
|
+
"node": ">=18"
|
|
178
|
+
},
|
|
179
|
+
"scripts": {
|
|
180
|
+
"build": "tsup",
|
|
181
|
+
"test": "vitest run",
|
|
182
|
+
"test:watch": "vitest",
|
|
183
|
+
"lint": "biome check src tests",
|
|
184
|
+
"lint:fix": "biome check --write src tests",
|
|
185
|
+
"typecheck": "tsc --noEmit"
|
|
186
|
+
}
|
|
187
|
+
}
|
package/README.md
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
# lynq
|
|
2
|
-
|
|
3
|
-
[](https://github.com/hogekai/lynq/actions/workflows/ci.yml)
|
|
4
|
-
[](https://www.npmjs.com/package/@lynq/lynq)
|
|
5
|
-
|
|
6
|
-
MCP servers are stateless by default. lynq makes them session-aware.
|
|
7
|
-
|
|
8
|
-
## The Problem
|
|
9
|
-
|
|
10
|
-
With the official SDK, adding session-aware tool visibility requires manual plumbing:
|
|
11
|
-
|
|
12
|
-
```ts
|
|
13
|
-
// Without lynq — manual session tracking, manual notifications
|
|
14
|
-
const sessions = new Map();
|
|
15
|
-
|
|
16
|
-
server.setRequestHandler(ListToolsRequestSchema, (req, extra) => {
|
|
17
|
-
const session = sessions.get(extra.sessionId);
|
|
18
|
-
const tools = [loginTool];
|
|
19
|
-
if (session?.authorized) tools.push(weatherTool); // manual filtering
|
|
20
|
-
return { tools };
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
server.setRequestHandler(CallToolRequestSchema, async (req, extra) => {
|
|
24
|
-
if (req.params.name === "login") {
|
|
25
|
-
sessions.set(extra.sessionId, { authorized: true });
|
|
26
|
-
server.sendToolListChanged(); // manual notification
|
|
27
|
-
}
|
|
28
|
-
// ...
|
|
29
|
-
});
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## The Solution
|
|
33
|
-
|
|
34
|
-
```ts
|
|
35
|
-
// With lynq — one line
|
|
36
|
-
server.tool("weather", guard(), config, handler);
|
|
37
|
-
// Client gets notified automatically. No manual wiring.
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## Install
|
|
41
|
-
|
|
42
|
-
```sh
|
|
43
|
-
npm install @lynq/lynq
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Quick Start
|
|
47
|
-
|
|
48
|
-
```ts
|
|
49
|
-
import { createMCPServer } from "@lynq/lynq";
|
|
50
|
-
import { guard } from "@lynq/lynq/guard";
|
|
51
|
-
import { z } from "zod";
|
|
52
|
-
|
|
53
|
-
const server = createMCPServer({ name: "my-server", version: "1.0.0" });
|
|
54
|
-
|
|
55
|
-
server.tool("login", {
|
|
56
|
-
input: z.object({ username: z.string(), password: z.string() }),
|
|
57
|
-
}, async (args, c) => {
|
|
58
|
-
const user = await authenticate(args.username, args.password);
|
|
59
|
-
c.session.set("user", user);
|
|
60
|
-
c.session.authorize("guard");
|
|
61
|
-
return c.text(`Welcome, ${user.name}`);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
server.tool("weather", guard(), {
|
|
65
|
-
description: "Get weather for a city",
|
|
66
|
-
input: z.object({ city: z.string() }),
|
|
67
|
-
}, async (args, c) => {
|
|
68
|
-
return c.text(JSON.stringify(await fetchWeather(args.city)));
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
await server.stdio();
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
```sh
|
|
75
|
-
npx tsx server.ts
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
## Features
|
|
79
|
-
|
|
80
|
-
- **Session-Scoped Visibility** — `authorize()` shows tools, `revoke()` hides them. Client notification is automatic.
|
|
81
|
-
- **Hono-Style Middleware** — Global via `server.use()`, per-tool inline. Three hooks: `onRegister`, `onCall`, `onResult`.
|
|
82
|
-
- **Built-in Middleware** — `guard()` `rateLimit()` `logger()` `truncate()` `credentials()` `some()` `every()` `except()`
|
|
83
|
-
- **Response Helpers** — `c.text()` `c.json()` `c.error()` `c.image()` — chainable: `c.text("done").json({ id: 1 })`
|
|
84
|
-
- **Elicitation** — `c.elicit.form(message, zodSchema)` for structured user input. `c.elicit.url()` for external flows.
|
|
85
|
-
- **Framework Adapters** — `server.http()` returns `(Request) => Response`. Mount in Hono, Express, Deno, Workers.
|
|
86
|
-
- **Test Helpers** — `createTestClient()` for in-memory testing. No transport setup.
|
|
87
|
-
- **Tiny Core** — One dependency. ESM only. No config files, no magic.
|
|
88
|
-
|
|
89
|
-
## Middleware Composition
|
|
90
|
-
|
|
91
|
-
```ts
|
|
92
|
-
import { guard } from "@lynq/lynq/guard";
|
|
93
|
-
import { rateLimit } from "@lynq/lynq/rate-limit";
|
|
94
|
-
import { logger } from "@lynq/lynq/logger";
|
|
95
|
-
|
|
96
|
-
server.use(logger()); // global
|
|
97
|
-
server.tool("search", guard(), rateLimit({ max: 10 }), config, handler); // per-tool stack
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
## Comparison
|
|
101
|
-
|
|
102
|
-
| | lynq | FastMCP | Official SDK |
|
|
103
|
-
|---|---|---|---|
|
|
104
|
-
| Per-tool middleware | Yes | No | No |
|
|
105
|
-
| Session-scoped visibility | Auto-notify | Manual | Manual |
|
|
106
|
-
| onResult hook | Yes | No | No |
|
|
107
|
-
| Response helpers | Chainable | Basic | No |
|
|
108
|
-
| Test helpers | Yes | No | No |
|
|
109
|
-
| HTTP server built-in | No (you choose) | Yes (opinionated) | No |
|
|
110
|
-
|
|
111
|
-
## Documentation
|
|
112
|
-
|
|
113
|
-
[https://hogekai.github.io/lynq/](https://hogekai.github.io/lynq/)
|
|
114
|
-
|
|
115
|
-
- [Quick Start](https://hogekai.github.io/lynq/getting-started/quick-start)
|
|
116
|
-
- [Middleware Concepts](https://hogekai.github.io/lynq/concepts/middleware)
|
|
117
|
-
- [Why lynq](https://hogekai.github.io/lynq/why-lynq)
|
|
118
|
-
- [API Reference](https://hogekai.github.io/lynq/api-reference/)
|
|
119
|
-
|
|
120
|
-
## License
|
|
121
|
-
|
|
122
|
-
MIT
|