@studiometa/forge-mcp 0.2.2 → 0.2.4
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 +61 -19
- package/dist/auth.d.ts +12 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +19 -1
- package/dist/auth.js.map +1 -1
- package/dist/crypto.d.ts +56 -0
- package/dist/crypto.d.ts.map +1 -0
- package/dist/crypto.js +110 -0
- package/dist/crypto.js.map +1 -0
- package/dist/handlers/auto-resolve.d.ts +24 -0
- package/dist/handlers/auto-resolve.d.ts.map +1 -0
- package/dist/handlers/batch.d.ts +14 -0
- package/dist/handlers/batch.d.ts.map +1 -0
- package/dist/handlers/context.d.ts +14 -0
- package/dist/handlers/context.d.ts.map +1 -0
- package/dist/handlers/help.d.ts.map +1 -1
- package/dist/handlers/index.d.ts.map +1 -1
- package/dist/handlers/schema.d.ts.map +1 -1
- package/dist/handlers/servers.d.ts +6 -1
- package/dist/handlers/servers.d.ts.map +1 -1
- package/dist/handlers/sites.d.ts +6 -1
- package/dist/handlers/sites.d.ts.map +1 -1
- package/dist/{http-BMOiJdyw.js → http-DN0I5GR6.js} +16 -4
- package/dist/http-DN0I5GR6.js.map +1 -0
- package/dist/http.d.ts +1 -1
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +2 -2
- package/dist/index.js +1 -1
- package/dist/oauth.d.ts +118 -0
- package/dist/oauth.d.ts.map +1 -0
- package/dist/oauth.js +571 -0
- package/dist/oauth.js.map +1 -0
- package/dist/server.d.ts +24 -6
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +33 -9
- package/dist/server.js.map +1 -1
- package/dist/tools.d.ts +1 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/{version-D3OFS3DQ.js → version-Gjth4BwC.js} +2799 -2450
- package/dist/version-Gjth4BwC.js.map +1 -0
- package/package.json +9 -1
- package/skills/SKILL.md +152 -29
- package/dist/http-BMOiJdyw.js.map +0 -1
- package/dist/version-D3OFS3DQ.js.map +0 -1
package/README.md
CHANGED
|
@@ -71,13 +71,17 @@ When enabled, the `forge_write` tool is not registered at all — only `forge`,
|
|
|
71
71
|
|
|
72
72
|
Safe, read-only queries. Annotated `readOnlyHint: true` so MCP clients can auto-approve.
|
|
73
73
|
|
|
74
|
-
**Actions**: `list`, `get`, `help`, `schema`
|
|
74
|
+
**Actions**: `list`, `get`, `resolve`, `context`, `help`, `schema`
|
|
75
75
|
|
|
76
76
|
```json
|
|
77
77
|
{ "resource": "servers", "action": "list" }
|
|
78
78
|
{ "resource": "servers", "action": "get", "id": "123" }
|
|
79
79
|
{ "resource": "sites", "action": "list", "server_id": "123" }
|
|
80
80
|
{ "resource": "servers", "action": "help" }
|
|
81
|
+
{ "resource": "servers", "action": "resolve", "query": "prod" }
|
|
82
|
+
{ "resource": "servers", "action": "context", "id": "123" }
|
|
83
|
+
{ "resource": "sites", "action": "context", "server_id": "123", "id": "456" }
|
|
84
|
+
{ "resource": "batch", "action": "run", "operations": [{ "resource": "servers", "action": "list" }, { "resource": "recipes", "action": "list" }] }
|
|
81
85
|
```
|
|
82
86
|
|
|
83
87
|
### `forge_write` — Write Operations
|
|
@@ -95,31 +99,69 @@ Mutating operations. Annotated `destructiveHint: true` so MCP clients always pro
|
|
|
95
99
|
|
|
96
100
|
### Resources & Actions
|
|
97
101
|
|
|
98
|
-
| Resource | Read Actions
|
|
99
|
-
| --------------- |
|
|
100
|
-
| servers | list, get
|
|
101
|
-
| sites | list, get
|
|
102
|
-
| deployments | list
|
|
103
|
-
| env | get
|
|
104
|
-
| nginx | get
|
|
105
|
-
| certificates | list, get
|
|
106
|
-
| databases | list, get
|
|
107
|
-
|
|
|
108
|
-
|
|
|
109
|
-
|
|
|
110
|
-
|
|
|
111
|
-
|
|
|
112
|
-
|
|
|
113
|
-
|
|
|
114
|
-
|
|
|
102
|
+
| Resource | Read Actions | Write Actions | Required Fields |
|
|
103
|
+
| --------------- | --------------------------- | ------------------------ | -------------------------- |
|
|
104
|
+
| servers | list, get, resolve, context | create, delete, reboot | id (for get/delete/reboot) |
|
|
105
|
+
| sites | list, get, resolve, context | create, delete | server_id |
|
|
106
|
+
| deployments | list, get | deploy, update | server_id, site_id |
|
|
107
|
+
| env | get | update | server_id, site_id |
|
|
108
|
+
| nginx | get | update | server_id, site_id |
|
|
109
|
+
| certificates | list, get | create, delete, activate | server_id, site_id |
|
|
110
|
+
| databases | list, get | create, delete | server_id |
|
|
111
|
+
| database-users | list, get | create, delete | server_id |
|
|
112
|
+
| daemons | list, get | create, delete, restart | server_id |
|
|
113
|
+
| firewall-rules | list, get | create, delete | server_id |
|
|
114
|
+
| ssh-keys | list, get | create, delete | server_id |
|
|
115
|
+
| security-rules | list, get | create, delete | server_id, site_id |
|
|
116
|
+
| redirect-rules | list, get | create, delete | server_id, site_id |
|
|
117
|
+
| monitors | list, get | create, delete | server_id |
|
|
118
|
+
| nginx-templates | list, get | create, update, delete | server_id |
|
|
119
|
+
| scheduled-jobs | list, get | create, delete | server_id |
|
|
120
|
+
| backups | list, get | create, delete | server_id |
|
|
121
|
+
| commands | list, get | create | server_id, site_id |
|
|
122
|
+
| recipes | list, get | create, delete, run | id (for get/delete/run) |
|
|
123
|
+
| user | get | — | — |
|
|
124
|
+
| batch | run | — | operations array |
|
|
125
|
+
|
|
126
|
+
### Auto-Resolve: Names Instead of IDs
|
|
127
|
+
|
|
128
|
+
The `server_id` and `site_id` fields accept **names** in addition to numeric IDs. When a non-numeric value is provided, it is resolved automatically via partial, case-insensitive match against the list of resources.
|
|
129
|
+
|
|
130
|
+
- `server_id: "prod"` → resolves to the server whose name contains "prod" (must be unique)
|
|
131
|
+
- `site_id: "example"` → resolves to the site whose domain contains "example" (requires `server_id`)
|
|
132
|
+
|
|
133
|
+
Use `action: "resolve"` explicitly when you want to search before committing to an ID:
|
|
134
|
+
|
|
135
|
+
```json
|
|
136
|
+
{ "resource": "servers", "action": "resolve", "query": "prod" }
|
|
137
|
+
{ "resource": "sites", "action": "resolve", "server_id": "123", "query": "example" }
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Resolution fails (and returns an error) when the query matches zero or more than one resource — in that case, use the numeric ID directly.
|
|
115
141
|
|
|
116
142
|
### Discovery
|
|
117
143
|
|
|
118
|
-
Use `action: "help"` with any resource:
|
|
144
|
+
Use `action: "help"` with any resource, or `action: "context"` to fetch a resource and all its sub-resources in one call:
|
|
119
145
|
|
|
120
146
|
```json
|
|
121
147
|
{ "resource": "servers", "action": "help" }
|
|
122
148
|
{ "resource": "deployments", "action": "help" }
|
|
149
|
+
{ "resource": "servers", "action": "context", "id": "123" }
|
|
150
|
+
{ "resource": "sites", "action": "context", "server_id": "123", "id": "456" }
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Use `resource: "batch"` to fan out multiple reads in a single round-trip (max 10 operations):
|
|
154
|
+
|
|
155
|
+
```json
|
|
156
|
+
{
|
|
157
|
+
"resource": "batch",
|
|
158
|
+
"action": "run",
|
|
159
|
+
"operations": [
|
|
160
|
+
{ "resource": "servers", "action": "list" },
|
|
161
|
+
{ "resource": "sites", "action": "list", "server_id": "123" },
|
|
162
|
+
{ "resource": "recipes", "action": "list" }
|
|
163
|
+
]
|
|
164
|
+
}
|
|
123
165
|
```
|
|
124
166
|
|
|
125
167
|
## Stdio-Only Tools
|
package/dist/auth.d.ts
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Authentication utilities for Forge MCP HTTP server
|
|
3
|
+
*
|
|
4
|
+
* Supports two token formats:
|
|
5
|
+
* 1. Raw Forge API token (backwards compatible)
|
|
6
|
+
* 2. Base64-encoded Forge API token (from OAuth flow)
|
|
7
|
+
*
|
|
8
|
+
* Detection heuristic: decode the token from base64, then re-encode.
|
|
9
|
+
* If the re-encoded string matches the original, it's a real base64 token
|
|
10
|
+
* and we use the decoded value. Otherwise, we treat it as a raw token.
|
|
3
11
|
*/
|
|
4
12
|
export interface ForgeCredentials {
|
|
5
13
|
apiToken: string;
|
|
6
14
|
}
|
|
7
15
|
/**
|
|
8
16
|
* Parse Bearer token containing Forge API credentials.
|
|
9
|
-
*
|
|
17
|
+
*
|
|
18
|
+
* Token formats:
|
|
19
|
+
* - Raw Forge API token (e.g., "Bearer my-api-token")
|
|
20
|
+
* - Base64-encoded token from OAuth flow (e.g., "Bearer base64(apiToken)")
|
|
10
21
|
*
|
|
11
22
|
* @param authHeader - Authorization header value (e.g., "Bearer <token>")
|
|
12
23
|
* @returns Parsed credentials or null if invalid
|
package/dist/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;CAClB;AA0BD;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,gBAAgB,GAAG,IAAI,CAwB9F"}
|
package/dist/auth.js
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* Try to decode a base64-encoded token.
|
|
3
|
+
* Returns the decoded string if re-encoding produces the original, null otherwise.
|
|
4
|
+
*
|
|
5
|
+
* Buffer.from(str, 'base64') never throws — it silently ignores invalid chars.
|
|
6
|
+
* So this function cannot fail, no try/catch needed.
|
|
7
|
+
*/
|
|
8
|
+
function tryDecodeBase64(token) {
|
|
9
|
+
const decoded = Buffer.from(token, "base64").toString("utf-8");
|
|
10
|
+
if (!decoded || decoded === token) return null;
|
|
11
|
+
if (Buffer.from(decoded).toString("base64") === token) return decoded;
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
2
15
|
* Parse Bearer token containing Forge API credentials.
|
|
3
|
-
*
|
|
16
|
+
*
|
|
17
|
+
* Token formats:
|
|
18
|
+
* - Raw Forge API token (e.g., "Bearer my-api-token")
|
|
19
|
+
* - Base64-encoded token from OAuth flow (e.g., "Bearer base64(apiToken)")
|
|
4
20
|
*
|
|
5
21
|
* @param authHeader - Authorization header value (e.g., "Bearer <token>")
|
|
6
22
|
* @returns Parsed credentials or null if invalid
|
|
@@ -11,6 +27,8 @@ function parseAuthHeader(authHeader) {
|
|
|
11
27
|
if (!match) return null;
|
|
12
28
|
const token = match[1].trim();
|
|
13
29
|
if (!token) return null;
|
|
30
|
+
const decoded = tryDecodeBase64(token);
|
|
31
|
+
if (decoded) return { apiToken: decoded };
|
|
14
32
|
return { apiToken: token };
|
|
15
33
|
}
|
|
16
34
|
export { parseAuthHeader };
|
package/dist/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","names":[],"sources":["../src/auth.ts"],"sourcesContent":["/**\n * Authentication utilities for Forge MCP HTTP server\n */\n\nexport interface ForgeCredentials {\n apiToken: string;\n}\n\n/**\n * Parse Bearer token containing Forge API credentials.\n * Token
|
|
1
|
+
{"version":3,"file":"auth.js","names":[],"sources":["../src/auth.ts"],"sourcesContent":["/**\n * Authentication utilities for Forge MCP HTTP server\n *\n * Supports two token formats:\n * 1. Raw Forge API token (backwards compatible)\n * 2. Base64-encoded Forge API token (from OAuth flow)\n *\n * Detection heuristic: decode the token from base64, then re-encode.\n * If the re-encoded string matches the original, it's a real base64 token\n * and we use the decoded value. Otherwise, we treat it as a raw token.\n */\n\nexport interface ForgeCredentials {\n apiToken: string;\n}\n\n/**\n * Try to decode a base64-encoded token.\n * Returns the decoded string if re-encoding produces the original, null otherwise.\n *\n * Buffer.from(str, 'base64') never throws — it silently ignores invalid chars.\n * So this function cannot fail, no try/catch needed.\n */\nfunction tryDecodeBase64(token: string): string | null {\n const decoded = Buffer.from(token, \"base64\").toString(\"utf-8\");\n\n // decoded must be non-empty and different from input\n if (!decoded || decoded === token) {\n return null;\n }\n\n // Re-encode and compare — if it roundtrips, it was genuinely base64\n const reEncoded = Buffer.from(decoded).toString(\"base64\");\n if (reEncoded === token) {\n return decoded;\n }\n\n return null;\n}\n\n/**\n * Parse Bearer token containing Forge API credentials.\n *\n * Token formats:\n * - Raw Forge API token (e.g., \"Bearer my-api-token\")\n * - Base64-encoded token from OAuth flow (e.g., \"Bearer base64(apiToken)\")\n *\n * @param authHeader - Authorization header value (e.g., \"Bearer <token>\")\n * @returns Parsed credentials or null if invalid\n */\nexport function parseAuthHeader(authHeader: string | undefined | null): ForgeCredentials | null {\n if (!authHeader) {\n return null;\n }\n\n const match = authHeader.match(/^Bearer\\s+(.+)$/i);\n if (!match) {\n return null;\n }\n\n const token = match[1].trim();\n\n if (!token) {\n return null;\n }\n\n // Try to decode as base64 (OAuth access token)\n const decoded = tryDecodeBase64(token);\n if (decoded) {\n return { apiToken: decoded };\n }\n\n // Treat as raw Forge API token (backwards compatible)\n return { apiToken: token };\n}\n"],"mappings":";;;;;;;AAuBA,SAAS,gBAAgB,OAA8B;CACrD,MAAM,UAAU,OAAO,KAAK,OAAO,SAAS,CAAC,SAAS,QAAQ;AAG9D,KAAI,CAAC,WAAW,YAAY,MAC1B,QAAO;AAKT,KADkB,OAAO,KAAK,QAAQ,CAAC,SAAS,SAAS,KACvC,MAChB,QAAO;AAGT,QAAO;;;;;;;;;;;;AAaT,SAAgB,gBAAgB,YAAgE;AAC9F,KAAI,CAAC,WACH,QAAO;CAGT,MAAM,QAAQ,WAAW,MAAM,mBAAmB;AAClD,KAAI,CAAC,MACH,QAAO;CAGT,MAAM,QAAQ,MAAM,GAAG,MAAM;AAE7B,KAAI,CAAC,MACH,QAAO;CAIT,MAAM,UAAU,gBAAgB,MAAM;AACtC,KAAI,QACF,QAAO,EAAE,UAAU,SAAS;AAI9B,QAAO,EAAE,UAAU,OAAO"}
|
package/dist/crypto.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cryptographic utilities for stateless OAuth tokens
|
|
3
|
+
*
|
|
4
|
+
* Uses AES-256-GCM for authenticated encryption.
|
|
5
|
+
* The authorization code contains encrypted credentials that can be
|
|
6
|
+
* decrypted without server-side storage.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Get the encryption secret from environment or generate a default.
|
|
10
|
+
* In production, OAUTH_SECRET should always be set.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getSecret(): string;
|
|
13
|
+
/**
|
|
14
|
+
* Encrypt data using AES-256-GCM
|
|
15
|
+
*
|
|
16
|
+
* Output format: base64url(salt + iv + authTag + ciphertext)
|
|
17
|
+
*
|
|
18
|
+
* @param plaintext - Data to encrypt
|
|
19
|
+
* @param secret - Encryption secret (defaults to OAUTH_SECRET env var)
|
|
20
|
+
* @returns Base64url-encoded encrypted data
|
|
21
|
+
*/
|
|
22
|
+
export declare function encrypt(plaintext: string, secret?: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Decrypt data encrypted with encrypt()
|
|
25
|
+
*
|
|
26
|
+
* @param ciphertext - Base64url-encoded encrypted data
|
|
27
|
+
* @param secret - Encryption secret (defaults to OAUTH_SECRET env var)
|
|
28
|
+
* @returns Decrypted plaintext
|
|
29
|
+
* @throws Error if decryption fails (invalid data or wrong secret)
|
|
30
|
+
*/
|
|
31
|
+
export declare function decrypt(ciphertext: string, secret?: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* Authorization code payload structure
|
|
34
|
+
*/
|
|
35
|
+
export interface AuthCodePayload {
|
|
36
|
+
apiToken: string;
|
|
37
|
+
codeChallenge?: string;
|
|
38
|
+
codeChallengeMethod?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Create an encrypted authorization code containing credentials and PKCE challenge
|
|
42
|
+
*
|
|
43
|
+
* @param credentials - Object with apiToken and optional PKCE params
|
|
44
|
+
* @param expiresInSeconds - Code expiration time (default: 5 minutes)
|
|
45
|
+
* @returns Encrypted authorization code
|
|
46
|
+
*/
|
|
47
|
+
export declare function createAuthCode(credentials: AuthCodePayload, expiresInSeconds?: number): string;
|
|
48
|
+
/**
|
|
49
|
+
* Decode and validate an authorization code
|
|
50
|
+
*
|
|
51
|
+
* @param code - Encrypted authorization code
|
|
52
|
+
* @returns Decoded payload with credentials and PKCE challenge
|
|
53
|
+
* @throws Error if code is invalid or expired
|
|
54
|
+
*/
|
|
55
|
+
export declare function decodeAuthCode(code: string): AuthCodePayload;
|
|
56
|
+
//# sourceMappingURL=crypto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../src/crypto.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAgBH;;;GAGG;AACH,wBAAgB,SAAS,IAAI,MAAM,CASlC;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,GAAE,MAAoB,GAAG,MAAM,CAa/E;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,GAAE,MAAoB,GAAG,MAAM,CAwBhF;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,eAAe,EAC5B,gBAAgB,GAAE,MAAY,GAC7B,MAAM,CAMR;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAc5D"}
|
package/dist/crypto.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { createCipheriv, createDecipheriv, randomBytes, scryptSync } from "node:crypto";
|
|
2
|
+
/**
|
|
3
|
+
* Cryptographic utilities for stateless OAuth tokens
|
|
4
|
+
*
|
|
5
|
+
* Uses AES-256-GCM for authenticated encryption.
|
|
6
|
+
* The authorization code contains encrypted credentials that can be
|
|
7
|
+
* decrypted without server-side storage.
|
|
8
|
+
*/
|
|
9
|
+
var ALGORITHM = "aes-256-gcm";
|
|
10
|
+
var IV_LENGTH = 12;
|
|
11
|
+
var AUTH_TAG_LENGTH = 16;
|
|
12
|
+
var SALT_LENGTH = 16;
|
|
13
|
+
/**
|
|
14
|
+
* Derive a 256-bit key from a password using scrypt
|
|
15
|
+
*/
|
|
16
|
+
function deriveKey(password, salt) {
|
|
17
|
+
return scryptSync(password, salt, 32);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Get the encryption secret from environment or generate a default.
|
|
21
|
+
* In production, OAUTH_SECRET should always be set.
|
|
22
|
+
*/
|
|
23
|
+
function getSecret() {
|
|
24
|
+
const secret = process.env.OAUTH_SECRET;
|
|
25
|
+
if (!secret) {
|
|
26
|
+
console.warn("WARNING: OAUTH_SECRET not set. Using default secret. Set OAUTH_SECRET in production!");
|
|
27
|
+
return "forge-mcp-default-secret-change-me";
|
|
28
|
+
}
|
|
29
|
+
return secret;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Encrypt data using AES-256-GCM
|
|
33
|
+
*
|
|
34
|
+
* Output format: base64url(salt + iv + authTag + ciphertext)
|
|
35
|
+
*
|
|
36
|
+
* @param plaintext - Data to encrypt
|
|
37
|
+
* @param secret - Encryption secret (defaults to OAUTH_SECRET env var)
|
|
38
|
+
* @returns Base64url-encoded encrypted data
|
|
39
|
+
*/
|
|
40
|
+
function encrypt(plaintext, secret = getSecret()) {
|
|
41
|
+
const salt = randomBytes(SALT_LENGTH);
|
|
42
|
+
const key = deriveKey(secret, salt);
|
|
43
|
+
const iv = randomBytes(IV_LENGTH);
|
|
44
|
+
const cipher = createCipheriv(ALGORITHM, key, iv);
|
|
45
|
+
const encrypted = Buffer.concat([cipher.update(plaintext, "utf8"), cipher.final()]);
|
|
46
|
+
const authTag = cipher.getAuthTag();
|
|
47
|
+
return Buffer.concat([
|
|
48
|
+
salt,
|
|
49
|
+
iv,
|
|
50
|
+
authTag,
|
|
51
|
+
encrypted
|
|
52
|
+
]).toString("base64url");
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Decrypt data encrypted with encrypt()
|
|
56
|
+
*
|
|
57
|
+
* @param ciphertext - Base64url-encoded encrypted data
|
|
58
|
+
* @param secret - Encryption secret (defaults to OAUTH_SECRET env var)
|
|
59
|
+
* @returns Decrypted plaintext
|
|
60
|
+
* @throws Error if decryption fails (invalid data or wrong secret)
|
|
61
|
+
*/
|
|
62
|
+
function decrypt(ciphertext, secret = getSecret()) {
|
|
63
|
+
try {
|
|
64
|
+
const combined = Buffer.from(ciphertext, "base64url");
|
|
65
|
+
const salt = combined.subarray(0, SALT_LENGTH);
|
|
66
|
+
const iv = combined.subarray(SALT_LENGTH, SALT_LENGTH + IV_LENGTH);
|
|
67
|
+
const authTag = combined.subarray(SALT_LENGTH + IV_LENGTH, SALT_LENGTH + IV_LENGTH + AUTH_TAG_LENGTH);
|
|
68
|
+
const encrypted = combined.subarray(SALT_LENGTH + IV_LENGTH + AUTH_TAG_LENGTH);
|
|
69
|
+
const decipher = createDecipheriv(ALGORITHM, deriveKey(secret, salt), iv, { authTagLength: AUTH_TAG_LENGTH });
|
|
70
|
+
decipher.setAuthTag(authTag);
|
|
71
|
+
return Buffer.concat([decipher.update(encrypted), decipher.final()]).toString("utf8");
|
|
72
|
+
} catch {
|
|
73
|
+
throw new Error("Decryption failed: invalid token or secret");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Create an encrypted authorization code containing credentials and PKCE challenge
|
|
78
|
+
*
|
|
79
|
+
* @param credentials - Object with apiToken and optional PKCE params
|
|
80
|
+
* @param expiresInSeconds - Code expiration time (default: 5 minutes)
|
|
81
|
+
* @returns Encrypted authorization code
|
|
82
|
+
*/
|
|
83
|
+
function createAuthCode(credentials, expiresInSeconds = 300) {
|
|
84
|
+
const payload = {
|
|
85
|
+
...credentials,
|
|
86
|
+
exp: Date.now() + expiresInSeconds * 1e3
|
|
87
|
+
};
|
|
88
|
+
return encrypt(JSON.stringify(payload));
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Decode and validate an authorization code
|
|
92
|
+
*
|
|
93
|
+
* @param code - Encrypted authorization code
|
|
94
|
+
* @returns Decoded payload with credentials and PKCE challenge
|
|
95
|
+
* @throws Error if code is invalid or expired
|
|
96
|
+
*/
|
|
97
|
+
function decodeAuthCode(code) {
|
|
98
|
+
const payload = JSON.parse(decrypt(code));
|
|
99
|
+
if (payload.exp && Date.now() > payload.exp) throw new Error("Authorization code expired");
|
|
100
|
+
const { apiToken, codeChallenge, codeChallengeMethod } = payload;
|
|
101
|
+
if (!apiToken) throw new Error("Invalid authorization code: missing credentials");
|
|
102
|
+
return {
|
|
103
|
+
apiToken,
|
|
104
|
+
codeChallenge,
|
|
105
|
+
codeChallengeMethod
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
export { createAuthCode, decodeAuthCode, decrypt, encrypt, getSecret };
|
|
109
|
+
|
|
110
|
+
//# sourceMappingURL=crypto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.js","names":[],"sources":["../src/crypto.ts"],"sourcesContent":["/**\n * Cryptographic utilities for stateless OAuth tokens\n *\n * Uses AES-256-GCM for authenticated encryption.\n * The authorization code contains encrypted credentials that can be\n * decrypted without server-side storage.\n */\n\nimport { createCipheriv, createDecipheriv, randomBytes, scryptSync } from \"node:crypto\";\n\nconst ALGORITHM = \"aes-256-gcm\";\nconst IV_LENGTH = 12; // GCM recommended IV length\nconst AUTH_TAG_LENGTH = 16;\nconst SALT_LENGTH = 16;\n\n/**\n * Derive a 256-bit key from a password using scrypt\n */\nfunction deriveKey(password: string, salt: Buffer): Buffer {\n return scryptSync(password, salt, 32);\n}\n\n/**\n * Get the encryption secret from environment or generate a default.\n * In production, OAUTH_SECRET should always be set.\n */\nexport function getSecret(): string {\n const secret = process.env.OAUTH_SECRET;\n if (!secret) {\n console.warn(\n \"WARNING: OAUTH_SECRET not set. Using default secret. Set OAUTH_SECRET in production!\",\n );\n return \"forge-mcp-default-secret-change-me\";\n }\n return secret;\n}\n\n/**\n * Encrypt data using AES-256-GCM\n *\n * Output format: base64url(salt + iv + authTag + ciphertext)\n *\n * @param plaintext - Data to encrypt\n * @param secret - Encryption secret (defaults to OAUTH_SECRET env var)\n * @returns Base64url-encoded encrypted data\n */\nexport function encrypt(plaintext: string, secret: string = getSecret()): string {\n const salt = randomBytes(SALT_LENGTH);\n const key = deriveKey(secret, salt);\n const iv = randomBytes(IV_LENGTH);\n\n const cipher = createCipheriv(ALGORITHM, key, iv);\n const encrypted = Buffer.concat([cipher.update(plaintext, \"utf8\"), cipher.final()]);\n const authTag = cipher.getAuthTag();\n\n // Combine: salt + iv + authTag + ciphertext\n const combined = Buffer.concat([salt, iv, authTag, encrypted]);\n\n return combined.toString(\"base64url\");\n}\n\n/**\n * Decrypt data encrypted with encrypt()\n *\n * @param ciphertext - Base64url-encoded encrypted data\n * @param secret - Encryption secret (defaults to OAUTH_SECRET env var)\n * @returns Decrypted plaintext\n * @throws Error if decryption fails (invalid data or wrong secret)\n */\nexport function decrypt(ciphertext: string, secret: string = getSecret()): string {\n try {\n const combined = Buffer.from(ciphertext, \"base64url\");\n\n // Extract components\n const salt = combined.subarray(0, SALT_LENGTH);\n const iv = combined.subarray(SALT_LENGTH, SALT_LENGTH + IV_LENGTH);\n const authTag = combined.subarray(\n SALT_LENGTH + IV_LENGTH,\n SALT_LENGTH + IV_LENGTH + AUTH_TAG_LENGTH,\n );\n const encrypted = combined.subarray(SALT_LENGTH + IV_LENGTH + AUTH_TAG_LENGTH);\n\n const key = deriveKey(secret, salt);\n\n const decipher = createDecipheriv(ALGORITHM, key, iv, { authTagLength: AUTH_TAG_LENGTH });\n decipher.setAuthTag(authTag);\n\n const decrypted = Buffer.concat([decipher.update(encrypted), decipher.final()]);\n\n return decrypted.toString(\"utf8\");\n } catch {\n throw new Error(\"Decryption failed: invalid token or secret\");\n }\n}\n\n/**\n * Authorization code payload structure\n */\nexport interface AuthCodePayload {\n apiToken: string;\n codeChallenge?: string;\n codeChallengeMethod?: string;\n}\n\n/**\n * Create an encrypted authorization code containing credentials and PKCE challenge\n *\n * @param credentials - Object with apiToken and optional PKCE params\n * @param expiresInSeconds - Code expiration time (default: 5 minutes)\n * @returns Encrypted authorization code\n */\nexport function createAuthCode(\n credentials: AuthCodePayload,\n expiresInSeconds: number = 300,\n): string {\n const payload = {\n ...credentials,\n exp: Date.now() + expiresInSeconds * 1000,\n };\n return encrypt(JSON.stringify(payload));\n}\n\n/**\n * Decode and validate an authorization code\n *\n * @param code - Encrypted authorization code\n * @returns Decoded payload with credentials and PKCE challenge\n * @throws Error if code is invalid or expired\n */\nexport function decodeAuthCode(code: string): AuthCodePayload {\n const payload = JSON.parse(decrypt(code));\n\n if (payload.exp && Date.now() > payload.exp) {\n throw new Error(\"Authorization code expired\");\n }\n\n const { apiToken, codeChallenge, codeChallengeMethod } = payload;\n\n if (!apiToken) {\n throw new Error(\"Invalid authorization code: missing credentials\");\n }\n\n return { apiToken, codeChallenge, codeChallengeMethod };\n}\n"],"mappings":";;;;;;;;AAUA,IAAM,YAAY;AAClB,IAAM,YAAY;AAClB,IAAM,kBAAkB;AACxB,IAAM,cAAc;;;;AAKpB,SAAS,UAAU,UAAkB,MAAsB;AACzD,QAAO,WAAW,UAAU,MAAM,GAAG;;;;;;AAOvC,SAAgB,YAAoB;CAClC,MAAM,SAAS,QAAQ,IAAI;AAC3B,KAAI,CAAC,QAAQ;AACX,UAAQ,KACN,uFACD;AACD,SAAO;;AAET,QAAO;;;;;;;;;;;AAYT,SAAgB,QAAQ,WAAmB,SAAiB,WAAW,EAAU;CAC/E,MAAM,OAAO,YAAY,YAAY;CACrC,MAAM,MAAM,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e,wBAAwB;AAEzD,KAAI,CAAC,SACH,OAAM,IAAI,MAAM,kDAAkD;AAGpE,QAAO;EAAE;EAAU;EAAe;EAAqB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ExecutorContext } from "@studiometa/forge-core";
|
|
2
|
+
import type { CommonArgs } from "./types.ts";
|
|
3
|
+
import type { ToolResult } from "./types.ts";
|
|
4
|
+
/**
|
|
5
|
+
* Result of auto-resolution. Either the args are updated with resolved IDs,
|
|
6
|
+
* or an error result is returned.
|
|
7
|
+
*/
|
|
8
|
+
export type AutoResolveResult = {
|
|
9
|
+
ok: true;
|
|
10
|
+
args: CommonArgs;
|
|
11
|
+
} | {
|
|
12
|
+
ok: false;
|
|
13
|
+
error: ToolResult;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Auto-resolve non-numeric server_id and site_id fields.
|
|
17
|
+
*
|
|
18
|
+
* Order matters: server_id is resolved first because site_id resolution
|
|
19
|
+
* requires a numeric server_id.
|
|
20
|
+
*
|
|
21
|
+
* Skipped for the 'resolve' action itself (it IS the resolve action).
|
|
22
|
+
*/
|
|
23
|
+
export declare function autoResolveIds(args: CommonArgs, executorContext: ExecutorContext): Promise<AutoResolveResult>;
|
|
24
|
+
//# sourceMappingURL=auto-resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-resolve.d.ts","sourceRoot":"","sources":["../../src/handlers/auto-resolve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAS7C;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,UAAU,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAE,CAAC;AAElG;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,UAAU,EAChB,eAAe,EAAE,eAAe,GAC/B,OAAO,CAAC,iBAAiB,CAAC,CA6E5B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Batch handler — executes multiple read operations in a single MCP call.
|
|
3
|
+
*
|
|
4
|
+
* Reduces round-trips for AI agents by running operations in parallel
|
|
5
|
+
* with Promise.allSettled, isolating per-operation failures.
|
|
6
|
+
*/
|
|
7
|
+
import type { CommonArgs, HandlerContext, ToolResult } from "./types.ts";
|
|
8
|
+
type RouteHandler = (resource: string, action: string, args: CommonArgs, ctx: HandlerContext) => Promise<ToolResult>;
|
|
9
|
+
/**
|
|
10
|
+
* Handle batch action — executes multiple read operations in parallel.
|
|
11
|
+
*/
|
|
12
|
+
export declare function handleBatch(action: string, args: CommonArgs, ctx: HandlerContext, routeToHandler: RouteHandler): Promise<ToolResult>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=batch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../../src/handlers/batch.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAKzE,KAAK,YAAY,GAAG,CAClB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,UAAU,EAChB,GAAG,EAAE,cAAc,KAChB,OAAO,CAAC,UAAU,CAAC,CAAC;AAIzB;;GAEG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,UAAU,EAChB,GAAG,EAAE,cAAc,EACnB,cAAc,EAAE,YAAY,GAC3B,OAAO,CAAC,UAAU,CAAC,CAuGrB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CommonArgs, HandlerContext, ToolResult } from "./types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Handle server context action — fetches server details plus all sub-resources
|
|
4
|
+
* (sites, databases, database users, daemons, firewall rules, scheduled jobs)
|
|
5
|
+
* in parallel in a single call.
|
|
6
|
+
*/
|
|
7
|
+
export declare function handleServerContext(args: CommonArgs, ctx: HandlerContext): Promise<ToolResult>;
|
|
8
|
+
/**
|
|
9
|
+
* Handle site context action — fetches site details plus all sub-resources
|
|
10
|
+
* (recent deployments, certificates, redirect rules, security rules)
|
|
11
|
+
* in parallel in a single call. Deployments are limited to the last 5.
|
|
12
|
+
*/
|
|
13
|
+
export declare function handleSiteContext(args: CommonArgs, ctx: HandlerContext): Promise<ToolResult>;
|
|
14
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/handlers/context.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGzE;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,UAAU,EAChB,GAAG,EAAE,cAAc,GAClB,OAAO,CAAC,UAAU,CAAC,CA0BrB;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,UAAU,EAChB,GAAG,EAAE,cAAc,GAClB,OAAO,CAAC,UAAU,CAAC,CA2BrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../src/handlers/help.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../src/handlers/help.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAyrB7C;;GAEG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAQvD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,UAAU,CAa/C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,OAAO,KAAK,EAA8B,UAAU,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,OAAO,KAAK,EAA8B,UAAU,EAAE,MAAM,YAAY,CAAC;AAgCzE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AA0E7C;;;;;GAKG;AACH,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,WAAW,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,GAChC,OAAO,CAAC,UAAU,CAAC,CAoHrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/handlers/schema.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/handlers/schema.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAkV7C;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAWzD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,UAAU,CAWjD"}
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import type { CommonArgs, HandlerContext, ToolResult } from "./types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Handle servers resource actions, intercepting the `context` action
|
|
4
|
+
* for rich single-call resource fetching.
|
|
5
|
+
*/
|
|
6
|
+
export declare function handleServers(action: string, args: CommonArgs, ctx: HandlerContext): Promise<ToolResult>;
|
|
2
7
|
//# sourceMappingURL=servers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"servers.d.ts","sourceRoot":"","sources":["../../src/handlers/servers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"servers.d.ts","sourceRoot":"","sources":["../../src/handlers/servers.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAsEzE;;;GAGG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,UAAU,EAChB,GAAG,EAAE,cAAc,GAClB,OAAO,CAAC,UAAU,CAAC,CAKrB"}
|
package/dist/handlers/sites.d.ts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import type { CommonArgs, HandlerContext, ToolResult } from "./types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Handle sites resource actions, intercepting the `context` action
|
|
4
|
+
* for rich single-call resource fetching.
|
|
5
|
+
*/
|
|
6
|
+
export declare function handleSites(action: string, args: CommonArgs, ctx: HandlerContext): Promise<ToolResult>;
|
|
2
7
|
//# sourceMappingURL=sites.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sites.d.ts","sourceRoot":"","sources":["../../src/handlers/sites.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sites.d.ts","sourceRoot":"","sources":["../../src/handlers/sites.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAqEzE;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,UAAU,EAChB,GAAG,EAAE,cAAc,GAClB,OAAO,CAAC,UAAU,CAAC,CAKrB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { a as INSTRUCTIONS, i as getTools, n as executeToolWithCredentials, t as VERSION } from "./version-
|
|
1
|
+
import { a as INSTRUCTIONS, i as getTools, n as executeToolWithCredentials, t as VERSION } from "./version-Gjth4BwC.js";
|
|
2
2
|
import { parseAuthHeader } from "./auth.js";
|
|
3
|
+
import { authorizeGetHandler, authorizePostHandler, oauthMetadataHandler, protectedResourceHandler, registerHandler, tokenHandler } from "./oauth.js";
|
|
3
4
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
4
5
|
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
5
6
|
import { randomUUID } from "node:crypto";
|
|
@@ -192,7 +193,12 @@ async function handleMcpRequest(req, res, sessions, options) {
|
|
|
192
193
|
const authHeader = req.headers.authorization;
|
|
193
194
|
const credentials = parseAuthHeader(authHeader);
|
|
194
195
|
if (!credentials) {
|
|
195
|
-
|
|
196
|
+
const host = req.headers.host || "localhost:3000";
|
|
197
|
+
const resourceMetadataUrl = `${req.headers["x-forwarded-proto"] || "http"}://${host}/.well-known/oauth-protected-resource`;
|
|
198
|
+
res.writeHead(401, {
|
|
199
|
+
"Content-Type": "application/json",
|
|
200
|
+
"WWW-Authenticate": `Bearer resource_metadata="${resourceMetadataUrl}"`
|
|
201
|
+
});
|
|
196
202
|
res.end(JSON.stringify({
|
|
197
203
|
jsonrpc: "2.0",
|
|
198
204
|
error: {
|
|
@@ -255,7 +261,7 @@ function createMcpRequestHandler(sessions, options) {
|
|
|
255
261
|
/* v8 ignore stop */
|
|
256
262
|
}
|
|
257
263
|
/**
|
|
258
|
-
* Create h3 app for health check
|
|
264
|
+
* Create h3 app for health check, service info, and OAuth endpoints.
|
|
259
265
|
* The MCP endpoint is handled separately by handleMcpRequest.
|
|
260
266
|
*/
|
|
261
267
|
function createHealthApp() {
|
|
@@ -270,8 +276,14 @@ function createHealthApp() {
|
|
|
270
276
|
app.get("/health", defineEventHandler(() => {
|
|
271
277
|
return { status: "ok" };
|
|
272
278
|
}));
|
|
279
|
+
app.get("/.well-known/oauth-authorization-server", oauthMetadataHandler);
|
|
280
|
+
app.get("/.well-known/oauth-protected-resource", protectedResourceHandler);
|
|
281
|
+
app.post("/register", registerHandler);
|
|
282
|
+
app.get("/authorize", authorizeGetHandler);
|
|
283
|
+
app.post("/authorize", authorizePostHandler);
|
|
284
|
+
app.post("/token", tokenHandler);
|
|
273
285
|
return app;
|
|
274
286
|
}
|
|
275
287
|
export { SessionManager as a, handleMcpRequest as i, createMcpRequestHandler as n, createMcpServer as r, createHealthApp as t };
|
|
276
288
|
|
|
277
|
-
//# sourceMappingURL=http-
|
|
289
|
+
//# sourceMappingURL=http-DN0I5GR6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-DN0I5GR6.js","names":[],"sources":["../src/sessions.ts","../src/http.ts"],"sourcesContent":["/**\n * Session manager for multi-tenant Streamable HTTP transport.\n *\n * Each MCP client session gets its own transport + server pair.\n * Sessions are identified by UUID and tracked in a Map.\n *\n * Supports automatic TTL-based cleanup of idle sessions to prevent\n * memory leaks from abandoned clients.\n */\n\nimport type { Server } from \"@modelcontextprotocol/sdk/server/index.js\";\nimport type { StreamableHTTPServerTransport } from \"@modelcontextprotocol/sdk/server/streamableHttp.js\";\n\n/**\n * A managed session: transport + MCP server pair.\n */\nexport interface ManagedSession {\n transport: StreamableHTTPServerTransport;\n server: Server;\n createdAt: number;\n lastActiveAt: number;\n}\n\nexport interface SessionManagerOptions {\n /**\n * Maximum idle time in milliseconds before a session is reaped.\n * Default: 30 minutes. Set to 0 to disable automatic cleanup.\n */\n ttl?: number;\n\n /**\n * How often to check for expired sessions, in milliseconds.\n * Default: 60 seconds.\n */\n sweepInterval?: number;\n}\n\nconst DEFAULT_TTL = 30 * 60 * 1000; // 30 minutes\nconst DEFAULT_SWEEP_INTERVAL = 60 * 1000; // 60 seconds\n\nexport class SessionManager {\n private sessions = new Map<string, ManagedSession>();\n private sweepTimer: ReturnType<typeof setInterval> | undefined;\n private readonly ttl: number;\n\n constructor(options?: SessionManagerOptions) {\n this.ttl = options?.ttl ?? DEFAULT_TTL;\n\n if (this.ttl > 0) {\n const interval = options?.sweepInterval ?? DEFAULT_SWEEP_INTERVAL;\n this.sweepTimer = setInterval(() => {\n this.sweep();\n }, interval);\n // Don't keep the process alive just for the sweep timer\n this.sweepTimer.unref();\n }\n }\n\n /**\n * Register a session after its ID has been assigned by the transport.\n */\n register(transport: StreamableHTTPServerTransport, server: Server): void {\n const sessionId = transport.sessionId;\n if (sessionId) {\n const now = Date.now();\n this.sessions.set(sessionId, {\n transport,\n server,\n createdAt: now,\n lastActiveAt: now,\n });\n }\n }\n\n /**\n * Look up a session by its ID and refresh its activity timestamp.\n */\n get(sessionId: string): ManagedSession | undefined {\n const session = this.sessions.get(sessionId);\n if (session) {\n session.lastActiveAt = Date.now();\n }\n return session;\n }\n\n /**\n * Remove a session and close its transport + server.\n */\n async remove(sessionId: string): Promise<void> {\n const session = this.sessions.get(sessionId);\n if (session) {\n this.sessions.delete(sessionId);\n await session.transport.close();\n await session.server.close();\n }\n }\n\n /**\n * Get the number of active sessions.\n */\n get size(): number {\n return this.sessions.size;\n }\n\n /**\n * Sweep expired sessions. Called automatically by the sweep timer.\n * Returns the number of sessions reaped.\n */\n sweep(): number {\n if (this.ttl <= 0) return 0;\n\n const now = Date.now();\n const expired: string[] = [];\n\n for (const [id, session] of this.sessions) {\n if (now - session.lastActiveAt > this.ttl) {\n expired.push(id);\n }\n }\n\n for (const id of expired) {\n // Fire-and-forget cleanup — don't block the sweep\n /* v8 ignore start */\n this.remove(id).catch(() => {});\n /* v8 ignore stop */\n }\n\n return expired.length;\n }\n\n /**\n * Close all sessions, stop the sweep timer, and clean up.\n */\n async closeAll(): Promise<void> {\n if (this.sweepTimer) {\n clearInterval(this.sweepTimer);\n this.sweepTimer = undefined;\n }\n\n const promises: Promise<void>[] = [];\n for (const [, session] of this.sessions) {\n promises.push(session.transport.close());\n promises.push(session.server.close());\n }\n await Promise.all(promises);\n this.sessions.clear();\n }\n}\n","/**\n * Streamable HTTP transport for Forge MCP Server\n *\n * Implements the official MCP Streamable HTTP transport specification (2025-03-26)\n * using the SDK's StreamableHTTPServerTransport.\n *\n * Architecture:\n * - Stateful mode with per-session transport+server pairs (multi-tenant)\n * - Auth via Bearer token → authInfo.token → handler extra.authInfo\n * - Session manager (injected) maps session IDs to transport+server instances\n * - Health/status endpoints handled by h3, MCP endpoint by the SDK transport\n */\n\nimport { randomUUID } from \"node:crypto\";\nimport type { IncomingMessage, ServerResponse } from \"node:http\";\n\nimport { Server } from \"@modelcontextprotocol/sdk/server/index.js\";\nimport { StreamableHTTPServerTransport } from \"@modelcontextprotocol/sdk/server/streamableHttp.js\";\nimport { CallToolRequestSchema, ListToolsRequestSchema } from \"@modelcontextprotocol/sdk/types.js\";\nimport { createApp, defineEventHandler, type H3 } from \"h3\";\n\nimport { parseAuthHeader } from \"./auth.ts\";\nimport { executeToolWithCredentials } from \"./handlers/index.ts\";\nimport { INSTRUCTIONS } from \"./instructions.ts\";\nimport {\n oauthMetadataHandler,\n protectedResourceHandler,\n registerHandler,\n authorizeGetHandler,\n authorizePostHandler,\n tokenHandler,\n} from \"./oauth.ts\";\nimport { SessionManager } from \"./sessions.ts\";\nimport { getTools } from \"./tools.ts\";\nimport { VERSION } from \"./version.ts\";\n\nexport { SessionManager } from \"./sessions.ts\";\n\n/**\n * Options for the HTTP MCP server.\n */\nexport interface HttpServerOptions {\n /** When true, forge_write tool is not registered and write operations are rejected. */\n readOnly?: boolean;\n}\n\n/**\n * Create a configured MCP Server instance for HTTP transport.\n *\n * Unlike stdio, HTTP mode does NOT include forge_configure/forge_get_config\n * because credentials come from the Authorization header per-request.\n */\nexport function createMcpServer(options?: HttpServerOptions): Server {\n const readOnly = options?.readOnly ?? false;\n const tools = getTools({ readOnly });\n\n const server = new Server(\n {\n name: \"forge-mcp\",\n version: VERSION,\n },\n {\n capabilities: {\n tools: {},\n },\n instructions: INSTRUCTIONS,\n },\n );\n\n server.setRequestHandler(ListToolsRequestSchema, async () => {\n return { tools };\n });\n\n server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {\n const { name, arguments: args } = request.params;\n const token = extra.authInfo?.token;\n\n /* v8 ignore start */\n if (!token) {\n return {\n content: [\n {\n type: \"text\" as const,\n text: \"Error: Authentication required. No token found in request.\",\n },\n ],\n structuredContent: {\n success: false,\n error: \"Authentication required. No token found in request.\",\n },\n isError: true,\n };\n }\n /* v8 ignore stop */\n\n // Reject write operations in read-only mode\n if (readOnly && name === \"forge_write\") {\n return {\n content: [\n {\n type: \"text\" as const,\n text: \"Error: Server is running in read-only mode. Write operations are disabled.\",\n },\n ],\n structuredContent: {\n success: false,\n error: \"Server is running in read-only mode. Write operations are disabled.\",\n },\n isError: true,\n };\n }\n\n try {\n const result = await executeToolWithCredentials(\n name,\n /* v8 ignore next */ (args as Record<string, unknown>) ?? {},\n { apiToken: token },\n );\n return result as unknown as Record<string, unknown>;\n } catch (error) {\n /* v8 ignore start */\n const message = error instanceof Error ? error.message : String(error);\n /* v8 ignore stop */\n return {\n content: [{ type: \"text\" as const, text: `Error: ${message}` }],\n structuredContent: { success: false, error: message },\n isError: true,\n };\n }\n });\n\n return server;\n}\n\n/**\n * Handle an MCP request using the Streamable HTTP transport.\n *\n * Routes requests based on whether they have a session ID:\n * - No session ID + initialize request → create new session\n * - Has session ID → route to existing session's transport\n *\n * @param req - Node.js IncomingMessage\n * @param res - Node.js ServerResponse\n * @param sessions - Session manager instance (injected)\n * @param options - Server options (read-only mode, etc.)\n */\nexport async function handleMcpRequest(\n req: IncomingMessage,\n res: ServerResponse,\n sessions: SessionManager,\n options?: HttpServerOptions,\n): Promise<void> {\n // Extract and validate auth\n const authHeader = req.headers.authorization;\n const credentials = parseAuthHeader(authHeader);\n\n if (!credentials) {\n // Build resource_metadata URL for the WWW-Authenticate header (RFC 9728)\n const host = req.headers.host || \"localhost:3000\";\n const protocol = (req.headers[\"x-forwarded-proto\"] as string) || \"http\";\n const resourceMetadataUrl = `${protocol}://${host}/.well-known/oauth-protected-resource`;\n\n res.writeHead(401, {\n \"Content-Type\": \"application/json\",\n \"WWW-Authenticate\": `Bearer resource_metadata=\"${resourceMetadataUrl}\"`,\n });\n res.end(\n JSON.stringify({\n jsonrpc: \"2.0\",\n error: {\n code: -32001,\n message: \"Authentication required. Provide a Bearer token with your Forge API token.\",\n },\n id: null,\n }),\n );\n return;\n }\n\n // Inject auth info for the SDK transport\n const authenticatedReq = req as IncomingMessage & {\n auth?: { token: string; clientId: string; scopes: string[] };\n };\n authenticatedReq.auth = {\n token: credentials.apiToken,\n clientId: \"forge-http-client\",\n scopes: [],\n };\n\n const sessionId = req.headers[\"mcp-session-id\"] as string | undefined;\n\n if (sessionId) {\n // Existing session — route to its transport\n const session = sessions.get(sessionId);\n if (!session) {\n res.writeHead(404, { \"Content-Type\": \"application/json\" });\n res.end(\n JSON.stringify({\n jsonrpc: \"2.0\",\n error: {\n code: -32000,\n message: \"Session not found. The session may have expired or been terminated.\",\n },\n id: null,\n }),\n );\n return;\n }\n\n await session.transport.handleRequest(authenticatedReq, res);\n return;\n }\n\n // No session ID — this should be an initialize request.\n // Create a new transport + server pair.\n const transport = new StreamableHTTPServerTransport({\n sessionIdGenerator: () => randomUUID(),\n });\n\n const server = createMcpServer(options);\n await server.connect(transport);\n\n // Set up cleanup on close\n transport.onclose = () => {\n const sid = transport.sessionId;\n /* v8 ignore start */\n if (sid) {\n sessions.remove(sid).catch(() => {\n // Ignore cleanup errors\n });\n }\n /* v8 ignore stop */\n };\n\n // Handle the request (this will set transport.sessionId during initialize)\n await transport.handleRequest(authenticatedReq, res);\n\n // After handling, register the session if the transport got a session ID\n /* v8 ignore start */\n if (transport.sessionId) {\n sessions.register(transport, server);\n } else {\n // No session was created (e.g., invalid request) — clean up\n await transport.close();\n await server.close();\n }\n /* v8 ignore stop */\n}\n\n/**\n * Create a request handler bound to a SessionManager instance.\n * Convenience factory for server.ts.\n */\nexport function createMcpRequestHandler(\n sessions: SessionManager,\n options?: HttpServerOptions,\n): (req: IncomingMessage, res: ServerResponse) => Promise<void> {\n /* v8 ignore start */\n return (req, res) => handleMcpRequest(req, res, sessions, options);\n /* v8 ignore stop */\n}\n\n/**\n * Create h3 app for health check, service info, and OAuth endpoints.\n * The MCP endpoint is handled separately by handleMcpRequest.\n */\nexport function createHealthApp(): H3 {\n const app = createApp();\n\n // Service info & health\n app.get(\n \"/\",\n defineEventHandler(() => {\n return { status: \"ok\", service: \"forge-mcp\", version: VERSION };\n }),\n );\n\n app.get(\n \"/health\",\n defineEventHandler(() => {\n return { status: \"ok\" };\n }),\n );\n\n // OAuth 2.1 endpoints\n app.get(\"/.well-known/oauth-authorization-server\", oauthMetadataHandler);\n app.get(\"/.well-known/oauth-protected-resource\", protectedResourceHandler);\n app.post(\"/register\", registerHandler);\n app.get(\"/authorize\", authorizeGetHandler);\n app.post(\"/authorize\", authorizePostHandler);\n app.post(\"/token\", tokenHandler);\n\n return app;\n}\n"],"mappings":";;;;;;;;AAqCA,IAAM,cAAc,OAAU;AAC9B,IAAM,yBAAyB,KAAK;AAEpC,IAAa,iBAAb,MAA4B;CAC1B,2BAAmB,IAAI,KAA6B;CACpD;CACA;CAEA,YAAY,SAAiC;AAC3C,OAAK,MAAM,SAAS,OAAO;AAE3B,MAAI,KAAK,MAAM,GAAG;GAChB,MAAM,WAAW,SAAS,iBAAiB;AAC3C,QAAK,aAAa,kBAAkB;AAClC,SAAK,OAAO;MACX,SAAS;AAEZ,QAAK,WAAW,OAAO;;;;;;CAO3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AAyB;AACvB,SAAO,EAAE,QAAQ,MAAM;GACvB,CACH;AAGD,KAAI,IAAI,2CAA2C,qBAAqB;AACxE,KAAI,IAAI,yCAAyC,yBAAyB;AAC1E,KAAI,KAAK,aAAa,gBAAgB;AACtC,KAAI,IAAI,cAAc,oBAAoB;AAC1C,KAAI,KAAK,cAAc,qBAAqB;AAC5C,KAAI,KAAK,UAAU,aAAa;AAEhC,QAAO"}
|
package/dist/http.d.ts
CHANGED
|
@@ -48,7 +48,7 @@ export declare function handleMcpRequest(req: IncomingMessage, res: ServerRespon
|
|
|
48
48
|
*/
|
|
49
49
|
export declare function createMcpRequestHandler(sessions: SessionManager, options?: HttpServerOptions): (req: IncomingMessage, res: ServerResponse) => Promise<void>;
|
|
50
50
|
/**
|
|
51
|
-
* Create h3 app for health check
|
|
51
|
+
* Create h3 app for health check, service info, and OAuth endpoints.
|
|
52
52
|
* The MCP endpoint is handled separately by handleMcpRequest.
|
|
53
53
|
*/
|
|
54
54
|
export declare function createHealthApp(): H3;
|
package/dist/http.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEjE,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAGnE,OAAO,EAAiC,KAAK,EAAE,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEjE,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAGnE,OAAO,EAAiC,KAAK,EAAE,EAAE,MAAM,IAAI,CAAC;AAa5D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAI/C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,uFAAuF;IACvF,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,MAAM,CAgFnE;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,QAAQ,EAAE,cAAc,EACxB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,IAAI,CAAC,CAgGf;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,cAAc,EACxB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAI9D;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,EAAE,CA2BpC"}
|
package/dist/http.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./version-
|
|
2
|
-
import { a as SessionManager, i as handleMcpRequest, n as createMcpRequestHandler, r as createMcpServer, t as createHealthApp } from "./http-
|
|
1
|
+
import "./version-Gjth4BwC.js";
|
|
2
|
+
import { a as SessionManager, i as handleMcpRequest, n as createMcpRequestHandler, r as createMcpServer, t as createHealthApp } from "./http-DN0I5GR6.js";
|
|
3
3
|
export { SessionManager, createHealthApp, createMcpRequestHandler, createMcpServer, handleMcpRequest };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { t as parseReadOnlyFlag } from "./flags-LFbdErsZ.js";
|
|
3
|
-
import { a as INSTRUCTIONS, i as getTools, n as executeToolWithCredentials, r as STDIO_ONLY_TOOLS, t as VERSION } from "./version-
|
|
3
|
+
import { a as INSTRUCTIONS, i as getTools, n as executeToolWithCredentials, r as STDIO_ONLY_TOOLS, t as VERSION } from "./version-Gjth4BwC.js";
|
|
4
4
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
5
5
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
6
6
|
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|