@peac/mcp-server 0.10.13 → 0.11.2
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 +109 -15
- package/dist/cli.cjs +634 -27
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.d.ts +5 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.mjs +634 -27
- package/dist/cli.mjs.map +1 -1
- package/dist/http-transport.d.ts +65 -0
- package/dist/http-transport.d.ts.map +1 -0
- package/dist/index.cjs +53 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +53 -6
- package/dist/index.mjs.map +1 -1
- package/dist/infra/constants.d.ts +7 -1
- package/dist/infra/constants.d.ts.map +1 -1
- package/dist/infra/path-safety.d.ts +3 -1
- package/dist/infra/path-safety.d.ts.map +1 -1
- package/dist/infra/policy.d.ts +9 -95
- package/dist/infra/policy.d.ts.map +1 -1
- package/dist/schemas/bundle.d.ts +4 -48
- package/dist/schemas/bundle.d.ts.map +1 -1
- package/dist/schemas/decode.d.ts +3 -33
- package/dist/schemas/decode.d.ts.map +1 -1
- package/dist/schemas/inspect.d.ts +4 -68
- package/dist/schemas/inspect.d.ts.map +1 -1
- package/dist/schemas/issue.d.ts +8 -89
- package/dist/schemas/issue.d.ts.map +1 -1
- package/dist/schemas/verify.d.ts +4 -66
- package/dist/schemas/verify.d.ts.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/session-manager.d.ts +59 -0
- package/dist/session-manager.d.ts.map +1 -0
- package/package.json +10 -6
- package/server.json +23 -0
- package/smithery.yaml +36 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Session Manager -- Mcp-Session-Id lifecycle, eviction, isolation
|
|
3
|
+
*
|
|
4
|
+
* Each HTTP session gets its own McpServer + StreamableHTTPServerTransport
|
|
5
|
+
* pair. This is the primary defense against CVE-2026-25536 (cross-client
|
|
6
|
+
* response data leak when a single transport is reused across connections).
|
|
7
|
+
*
|
|
8
|
+
* INVARIANT: NEVER reuse a single transport instance across multiple
|
|
9
|
+
* client sessions. Each session is fully isolated.
|
|
10
|
+
*/
|
|
11
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
12
|
+
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
13
|
+
export interface SessionEntry {
|
|
14
|
+
readonly sessionId: string;
|
|
15
|
+
readonly server: McpServer;
|
|
16
|
+
readonly transport: StreamableHTTPServerTransport;
|
|
17
|
+
readonly createdAt: number;
|
|
18
|
+
readonly clientIp: string;
|
|
19
|
+
lastSeen: number;
|
|
20
|
+
}
|
|
21
|
+
export interface SessionManagerOptions {
|
|
22
|
+
/** Max idle time before eviction (ms). Default: 30 min */
|
|
23
|
+
ttlMs?: number;
|
|
24
|
+
/** Max concurrent sessions. Default: 100 */
|
|
25
|
+
maxSessions?: number;
|
|
26
|
+
/** Max sessions per client IP. Default: 10 */
|
|
27
|
+
maxSessionsPerIp?: number;
|
|
28
|
+
/** Eviction sweep interval (ms). Default: 60s */
|
|
29
|
+
sweepIntervalMs?: number;
|
|
30
|
+
}
|
|
31
|
+
type ServerFactory = () => McpServer;
|
|
32
|
+
export declare class SessionManager {
|
|
33
|
+
private readonly options;
|
|
34
|
+
private readonly sessions;
|
|
35
|
+
private readonly ipSessionCount;
|
|
36
|
+
private readonly ttlMs;
|
|
37
|
+
private readonly maxSessions;
|
|
38
|
+
private readonly maxSessionsPerIp;
|
|
39
|
+
private sweepTimer;
|
|
40
|
+
constructor(options?: SessionManagerOptions);
|
|
41
|
+
/** Start periodic eviction sweep */
|
|
42
|
+
startSweep(): void;
|
|
43
|
+
/** Create a new isolated session with its own McpServer + transport */
|
|
44
|
+
createSession(serverFactory: ServerFactory, clientIp?: string): Promise<SessionEntry>;
|
|
45
|
+
/** Look up an existing session by ID */
|
|
46
|
+
getSession(sessionId: string): SessionEntry | undefined;
|
|
47
|
+
/** Terminate and clean up a specific session */
|
|
48
|
+
terminateSession(sessionId: string): Promise<boolean>;
|
|
49
|
+
/** Terminate all sessions and stop sweep */
|
|
50
|
+
cleanup(): Promise<void>;
|
|
51
|
+
/** Get current session count */
|
|
52
|
+
get size(): number;
|
|
53
|
+
/** Evict sessions past TTL */
|
|
54
|
+
private evictStale;
|
|
55
|
+
/** Decrement per-IP session count, removing the key when it reaches 0 */
|
|
56
|
+
private decrementIpCount;
|
|
57
|
+
}
|
|
58
|
+
export {};
|
|
59
|
+
//# sourceMappingURL=session-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-manager.d.ts","sourceRoot":"","sources":["../src/session-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AAEnG,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,6BAA6B,CAAC;IAClD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,qBAAqB;IACpC,0DAA0D;IAC1D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4CAA4C;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8CAA8C;IAC9C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iDAAiD;IACjD,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,KAAK,aAAa,GAAG,MAAM,SAAS,CAAC;AAErC,qBAAa,cAAc;IAQb,OAAO,CAAC,QAAQ,CAAC,OAAO;IAPpC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmC;IAC5D,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA6B;IAC5D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;IAC1C,OAAO,CAAC,UAAU,CAA6C;gBAElC,OAAO,GAAE,qBAA0B;IAMhE,oCAAoC;IACpC,UAAU,IAAI,IAAI;IAMlB,uEAAuE;IACjE,aAAa,CAAC,aAAa,EAAE,aAAa,EAAE,QAAQ,SAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IAwC9F,wCAAwC;IACxC,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAQvD,gDAAgD;IAC1C,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAe3D,4CAA4C;IACtC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAsB9B,gCAAgC;IAChC,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,8BAA8B;IAC9B,OAAO,CAAC,UAAU;IAalB,yEAAyE;IACzE,OAAO,CAAC,gBAAgB;CAQzB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peac/mcp-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.2",
|
|
4
4
|
"description": "PEAC receipt operations as MCP tools (verify, inspect, decode)",
|
|
5
|
+
"mcpName": "io.github.peacprotocol/peac",
|
|
5
6
|
"main": "dist/index.cjs",
|
|
6
7
|
"types": "dist/index.d.ts",
|
|
7
8
|
"bin": {
|
|
@@ -33,7 +34,9 @@
|
|
|
33
34
|
},
|
|
34
35
|
"files": [
|
|
35
36
|
"dist",
|
|
36
|
-
"README.md"
|
|
37
|
+
"README.md",
|
|
38
|
+
"server.json",
|
|
39
|
+
"smithery.yaml"
|
|
37
40
|
],
|
|
38
41
|
"publishConfig": {
|
|
39
42
|
"access": "public",
|
|
@@ -42,10 +45,11 @@
|
|
|
42
45
|
"dependencies": {
|
|
43
46
|
"@modelcontextprotocol/sdk": "~1.27.0",
|
|
44
47
|
"commander": "^11.0.0",
|
|
45
|
-
"zod": "^3.
|
|
46
|
-
"@peac/
|
|
47
|
-
"@peac/
|
|
48
|
-
"@peac/
|
|
48
|
+
"zod": "^4.3.6",
|
|
49
|
+
"@peac/crypto": "0.11.2",
|
|
50
|
+
"@peac/schema": "0.11.2",
|
|
51
|
+
"@peac/kernel": "0.11.2",
|
|
52
|
+
"@peac/protocol": "0.11.2"
|
|
49
53
|
},
|
|
50
54
|
"devDependencies": {
|
|
51
55
|
"@types/node": "^22.0.0",
|
package/server.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
|
+
"name": "io.github.peacprotocol/peac",
|
|
4
|
+
"title": "PEAC Protocol",
|
|
5
|
+
"description": "Verify, inspect, decode, issue, and bundle PEAC receipts. Portable, offline-verifiable evidence.",
|
|
6
|
+
"repository": {
|
|
7
|
+
"url": "https://github.com/peacprotocol/peac",
|
|
8
|
+
"source": "github",
|
|
9
|
+
"subfolder": "packages/mcp-server"
|
|
10
|
+
},
|
|
11
|
+
"version": "0.11.2",
|
|
12
|
+
"websiteUrl": "https://www.peacprotocol.org",
|
|
13
|
+
"packages": [
|
|
14
|
+
{
|
|
15
|
+
"registryType": "npm",
|
|
16
|
+
"identifier": "@peac/mcp-server",
|
|
17
|
+
"version": "0.11.2",
|
|
18
|
+
"transport": {
|
|
19
|
+
"type": "stdio"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
package/smithery.yaml
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Smithery configuration for @peac/mcp-server
|
|
2
|
+
# Docs: https://smithery.ai/docs/build/project-config
|
|
3
|
+
# Transport: stdio (local install via npm). Streamable HTTP gateway path
|
|
4
|
+
# planned for future release (server already supports --transport http).
|
|
5
|
+
|
|
6
|
+
startCommand:
|
|
7
|
+
type: stdio
|
|
8
|
+
configSchema:
|
|
9
|
+
type: object
|
|
10
|
+
properties:
|
|
11
|
+
issuerKey:
|
|
12
|
+
type: string
|
|
13
|
+
description: >
|
|
14
|
+
Ed25519 JWK for receipt issuance (optional; read-only tools
|
|
15
|
+
work without it). Pass as env:VAR or file:/path.
|
|
16
|
+
issuerId:
|
|
17
|
+
type: string
|
|
18
|
+
description: 'Issuer URI (e.g., https://your-service.example.com)'
|
|
19
|
+
bundleDir:
|
|
20
|
+
type: string
|
|
21
|
+
description: Directory for evidence bundle output (optional)
|
|
22
|
+
jwksFile:
|
|
23
|
+
type: string
|
|
24
|
+
description: JWKS file for verifier key resolution (optional)
|
|
25
|
+
commandFunction: |-
|
|
26
|
+
(config) => {
|
|
27
|
+
const args = ['-y', '@peac/mcp-server'];
|
|
28
|
+
if (config.issuerKey) { args.push('--issuer-key', config.issuerKey); }
|
|
29
|
+
if (config.issuerId) { args.push('--issuer-id', config.issuerId); }
|
|
30
|
+
if (config.bundleDir) { args.push('--bundle-dir', config.bundleDir); }
|
|
31
|
+
if (config.jwksFile) { args.push('--jwks-file', config.jwksFile); }
|
|
32
|
+
return { command: 'npx', args };
|
|
33
|
+
}
|
|
34
|
+
exampleConfig:
|
|
35
|
+
issuerKey: 'env:PEAC_ISSUER_KEY'
|
|
36
|
+
issuerId: 'https://your-service.example.com'
|