@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.
Files changed (2) hide show
  1. package/package.json +186 -200
  2. package/README.md +0 -122
package/package.json CHANGED
@@ -1,201 +1,187 @@
1
1
  {
2
- "name": "@lynq/lynq",
3
- "version": "0.6.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
- "scripts": {
117
- "build": "tsup",
118
- "test": "vitest run",
119
- "test:watch": "vitest",
120
- "lint": "biome check src tests",
121
- "lint:fix": "biome check --write src tests",
122
- "typecheck": "tsc --noEmit",
123
- "docs:api": "typedoc",
124
- "docs:dev": "vitepress dev docs",
125
- "docs:build": "vitepress build docs",
126
- "docs:preview": "vitepress preview docs",
127
- "prepublishOnly": "pnpm build"
128
- },
129
- "dependencies": {
130
- "@modelcontextprotocol/sdk": "^1.27.0"
131
- },
132
- "devDependencies": {
133
- "@biomejs/biome": "^1.9.0",
134
- "@types/express": "^5.0.6",
135
- "express": "^5.2.1",
136
- "hono": "^4.12.5",
137
- "jose": "^6.2.1",
138
- "stripe": "^20.4.1",
139
- "tsup": "^8.0.0",
140
- "typedoc": "^0.28.17",
141
- "typedoc-plugin-markdown": "^4.10.0",
142
- "typescript": "^5.6.0",
143
- "vitepress": "^1.6.4",
144
- "vitest": "^2.0.0",
145
- "zod": "^3.24.0"
146
- },
147
- "peerDependencies": {
148
- "express": "^5.0.0",
149
- "hono": "^4.0.0",
150
- "jose": "^6.0.0",
151
- "stripe": "^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0",
152
- "zod": "^3.0.0"
153
- },
154
- "peerDependenciesMeta": {
155
- "zod": {
156
- "optional": true
157
- },
158
- "hono": {
159
- "optional": true
160
- },
161
- "express": {
162
- "optional": true
163
- },
164
- "jose": {
165
- "optional": true
166
- },
167
- "stripe": {
168
- "optional": true
169
- }
170
- },
171
- "publishConfig": {
172
- "access": "public"
173
- },
174
- "keywords": [
175
- "mcp",
176
- "model-context-protocol",
177
- "framework",
178
- "middleware",
179
- "ai",
180
- "agent"
181
- ],
182
- "repository": {
183
- "type": "git",
184
- "url": "https://github.com/hogekai/lynq"
185
- },
186
- "bugs": {
187
- "url": "https://github.com/hogekai/lynq/issues"
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
- [![CI](https://github.com/hogekai/lynq/actions/workflows/ci.yml/badge.svg)](https://github.com/hogekai/lynq/actions/workflows/ci.yml)
4
- [![npm](https://img.shields.io/npm/v/@lynq/lynq)](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