Skip to content

Commit 47c9258

Browse files
authored
Merge pull request #10 from code-rabi/benr/enhance-stability-and-security
fix: npm audit issues and stability bugs
2 parents 9782b2a + d1abb3a commit 47c9258

17 files changed

Lines changed: 805 additions & 690 deletions

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ jobs:
2323
- name: Install dependencies
2424
run: npm ci
2525

26+
- name: Security audit
27+
run: npm audit
28+
2629
- name: Typecheck
2730
run: npm run typecheck
2831

‎README.md‎

Lines changed: 50 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ process.on("SIGTERM", async () => {
171171

172172
## Static startup
173173

174-
Enable some or ALL toolsets at bootstrap. Note: provide a server or factory:
174+
Enable some or ALL toolsets at bootstrap. In STATIC mode, a single server instance is created and reused for all clients:
175175

176176
```ts
177177
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
@@ -181,26 +181,30 @@ const staticCatalog = {
181181
quotes: { name: "Quotes", description: "Market quotes", modules: ["quotes"] },
182182
};
183183

184+
// Load specific toolsets
184185
createMcpServer({
185186
catalog: staticCatalog,
186187
startup: { mode: "STATIC", toolsets: ["search", "quotes"] },
187188
http: { port: 3001 },
188-
server: new McpServer({
189-
name: "static-1",
190-
version: "0.0.0",
191-
capabilities: { tools: { listChanged: false } },
192-
}),
189+
createServer: () =>
190+
new McpServer({
191+
name: "static-1",
192+
version: "0.0.0",
193+
capabilities: { tools: { listChanged: false } },
194+
}),
193195
});
194196

197+
// Load ALL toolsets
195198
createMcpServer({
196199
catalog: staticCatalog,
197200
startup: { mode: "STATIC", toolsets: "ALL" },
198201
http: { port: 3002 },
199-
server: new McpServer({
200-
name: "static-2",
201-
version: "0.0.0",
202-
capabilities: { tools: { listChanged: false } },
203-
}),
202+
createServer: () =>
203+
new McpServer({
204+
name: "static-2",
205+
version: "0.0.0",
206+
capabilities: { tools: { listChanged: false } },
207+
}),
204208
});
205209
```
206210

@@ -664,9 +668,11 @@ Startup precedence and validation
664668

665669
#### options.registerMetaTools (optional)
666670

667-
`boolean` (default: true in DYNAMIC mode; false in STATIC unless explicitly set)
671+
`boolean` (default: true in DYNAMIC mode; false in STATIC mode)
668672

669-
- Whether to register management tools like `enable_toolset`, `disable_toolset`, `list_tools`.
673+
- Whether to register meta-tools for toolset management.
674+
- In DYNAMIC mode: Registers all meta-tools (`enable_toolset`, `disable_toolset`, `list_toolsets`, `describe_toolset`, `list_tools`).
675+
- In STATIC mode: Only registers `list_tools` (other meta-tools are not applicable since toolsets are fixed at startup).
670676

671677
#### options.exposurePolicy (optional)
672678

@@ -805,13 +811,17 @@ Same as `createMcpServer` - see [options.moduleLoaders](#optionsmoduleloaders-op
805811

806812
`ExposurePolicy` (partial support)
807813

808-
Permission-based servers override certain policy fields:
814+
Permission-based servers only support `namespaceToolsWithSetKey`. Other policy fields are ignored because toolset access is controlled by permissions:
815+
816+
| Field | Support |
817+
| -------------------------- | ------------------------------------------------- |
818+
| `namespaceToolsWithSetKey` | ✅ Supported (default: true) |
819+
| `allowlist` | ⚠️ Ignored (determined by client permissions) |
820+
| `denylist` | ⚠️ Ignored (use permissions instead) |
821+
| `maxActiveToolsets` | ⚠️ Ignored (determined by permission count) |
822+
| `onLimitExceeded` | ⚠️ Ignored (no toolset limits enforced) |
809823

810-
- `allowlist`: Set automatically based on resolved permissions (cannot be manually configured)
811-
- `maxActiveToolsets`: Set automatically to match permission count
812-
- `namespaceToolsWithSetKey`: Supported (default: true)
813-
- `denylist`: Not supported (use permissions instead)
814-
- `onLimitExceeded`: Not applicable
824+
**Note:** If you provide ignored options, the server will log warnings at startup to alert you.
815825

816826
#### options.http (optional)
817827

@@ -831,11 +841,21 @@ Same as `createMcpServer` - see [options.context](#optionscontext-optional).
831841

832842
### Meta-tools
833843

834-
Enabled by default when mode is DYNAMIC (or when `registerMetaTools` is true):
844+
Meta-tools are registered based on mode:
845+
846+
**DYNAMIC mode** (registered by default, or when `registerMetaTools` is true):
847+
848+
- `enable_toolset` - Enable a toolset by name
849+
- `disable_toolset` - Disable a toolset by name (state only; tools remain registered)
850+
- `list_toolsets` - List available toolsets with active status
851+
- `describe_toolset` - Describe a specific toolset with definition and tools
852+
- `list_tools` - List currently registered tool names
853+
854+
**STATIC mode** (when `registerMetaTools` is true):
855+
856+
- `list_tools` - List currently registered tool names
835857

836-
- `enable_toolset`, `disable_toolset`, `list_tools`
837-
Only in DYNAMIC mode:
838-
- `list_toolsets`, `describe_toolset`
858+
Note: In STATIC mode, `enable_toolset`, `disable_toolset`, `list_toolsets`, and `describe_toolset` are not available since toolsets are fixed at startup.
839859

840860
## Permission-based client integration
841861

@@ -1344,17 +1364,19 @@ Note on dynamic mode: Both direct and module-produced tools are supported. Modul
13441364

13451365
## Startup modes
13461366

1347-
The server operates in one of two primary modes (legacy load-all is not recommended here):
1367+
The server operates in one of two primary modes:
13481368

1349-
1. Dynamic mode (startup.mode = "DYNAMIC")
1369+
1. **Dynamic mode** (`startup.mode = "DYNAMIC"`)
13501370

1351-
- Starts with meta-tools for runtime management: `enable_toolset`, `disable_toolset`, `list_toolsets`, `describe_toolset`, and `list_tools` (always available)
1371+
- All meta-tools registered: `enable_toolset`, `disable_toolset`, `list_toolsets`, `describe_toolset`, `list_tools`
13521372
- Tools are loaded on-demand via meta-tool calls
1373+
- Each client gets an isolated server instance
13531374
- Best for flexible, task-specific workflows where tool needs change
13541375

1355-
2. Static mode (startup.mode = "STATIC")
1376+
2. **Static mode** (`startup.mode = "STATIC"`)
13561377
- Pre-loads specific toolsets at startup (`toolsets` array or "ALL")
1357-
- Meta-tools limited to `list_tools` by default
1378+
- Only `list_tools` meta-tool is available (toolsets cannot be changed at runtime)
1379+
- A single server instance is reused for all clients
13581380
- Best for known, consistent tool requirements
13591381

13601382
## License

0 commit comments

Comments
 (0)