mcpflare 0.2.1
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/CHANGELOG.md +68 -0
- package/LICENSE +22 -0
- package/README.md +371 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +1617 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +19 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/mcp-handler.d.ts +34 -0
- package/dist/server/mcp-handler.d.ts.map +1 -0
- package/dist/server/mcp-handler.js +1524 -0
- package/dist/server/mcp-handler.js.map +1 -0
- package/dist/server/metrics-collector.d.ts +30 -0
- package/dist/server/metrics-collector.d.ts.map +1 -0
- package/dist/server/metrics-collector.js +85 -0
- package/dist/server/metrics-collector.js.map +1 -0
- package/dist/server/schema-converter.d.ts +9 -0
- package/dist/server/schema-converter.d.ts.map +1 -0
- package/dist/server/schema-converter.js +82 -0
- package/dist/server/schema-converter.js.map +1 -0
- package/dist/server/worker-manager.d.ts +48 -0
- package/dist/server/worker-manager.d.ts.map +1 -0
- package/dist/server/worker-manager.js +1746 -0
- package/dist/server/worker-manager.js.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/mcp.d.ts +495 -0
- package/dist/types/mcp.d.ts.map +1 -0
- package/dist/types/mcp.js +80 -0
- package/dist/types/mcp.js.map +1 -0
- package/dist/types/worker.d.ts +35 -0
- package/dist/types/worker.d.ts.map +1 -0
- package/dist/types/worker.js +2 -0
- package/dist/types/worker.js.map +1 -0
- package/dist/utils/config-manager.d.ts +64 -0
- package/dist/utils/config-manager.d.ts.map +1 -0
- package/dist/utils/config-manager.js +556 -0
- package/dist/utils/config-manager.js.map +1 -0
- package/dist/utils/env-selector.d.ts +4 -0
- package/dist/utils/env-selector.d.ts.map +1 -0
- package/dist/utils/env-selector.js +127 -0
- package/dist/utils/env-selector.js.map +1 -0
- package/dist/utils/errors.d.ts +19 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +37 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/logger.d.ts +4 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +27 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/mcp-registry.d.ts +108 -0
- package/dist/utils/mcp-registry.d.ts.map +1 -0
- package/dist/utils/mcp-registry.js +298 -0
- package/dist/utils/mcp-registry.js.map +1 -0
- package/dist/utils/progress-indicator.d.ts +14 -0
- package/dist/utils/progress-indicator.d.ts.map +1 -0
- package/dist/utils/progress-indicator.js +82 -0
- package/dist/utils/progress-indicator.js.map +1 -0
- package/dist/utils/settings-manager.d.ts +19 -0
- package/dist/utils/settings-manager.d.ts.map +1 -0
- package/dist/utils/settings-manager.js +78 -0
- package/dist/utils/settings-manager.js.map +1 -0
- package/dist/utils/token-calculator.d.ts +34 -0
- package/dist/utils/token-calculator.d.ts.map +1 -0
- package/dist/utils/token-calculator.js +167 -0
- package/dist/utils/token-calculator.js.map +1 -0
- package/dist/utils/validation.d.ts +4 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +36 -0
- package/dist/utils/validation.js.map +1 -0
- package/dist/utils/wrangler-formatter.d.ts +37 -0
- package/dist/utils/wrangler-formatter.d.ts.map +1 -0
- package/dist/utils/wrangler-formatter.js +302 -0
- package/dist/utils/wrangler-formatter.js.map +1 -0
- package/dist/worker/runtime.d.ts +34 -0
- package/dist/worker/runtime.d.ts.map +1 -0
- package/dist/worker/runtime.js +166 -0
- package/dist/worker/runtime.js.map +1 -0
- package/package.json +83 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.2.1 (2026-01-17)
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add enterprise security hardening and automated release process ([e317d90](https://github.com/jgentes/mcpflare/commit/e317d90ef27a02f496de75997edd0461e80e674d))
|
|
8
|
+
* Add install command and MCP discovery/transparency features ([5e9eba6](https://github.com/jgentes/mcpflare/commit/5e9eba646330565b61599bee06259effab3a03c0))
|
|
9
|
+
* add unrestricted network mode and UI warning ([a9272c0](https://github.com/jgentes/mcpflare/commit/a9272c0b62b87248d0bfe3dec9a3c48a7eed8264))
|
|
10
|
+
* Add VS Code extension for MCP Guard configuration ([94ba5e7](https://github.com/jgentes/mcpflare/commit/94ba5e75f080503fa0423eb5ae0c05c6b8681084))
|
|
11
|
+
* **cli:** add token savings analysis and disk-based metrics persistence ([40186a0](https://github.com/jgentes/mcpflare/commit/40186a0f4dcf85173909654efc49aa16d42d0ce6))
|
|
12
|
+
* enforce per-MCP network allowlists ([8b179ba](https://github.com/jgentes/mcpflare/commit/8b179ba8ec236488955a2b9d9c01f4444bd29417))
|
|
13
|
+
* **extension:** add connection diagnostics and fix Streamable HTTP session handling ([3ef6570](https://github.com/jgentes/mcpflare/commit/3ef6570a3b89200c513ea9d8f44dff698027b47e))
|
|
14
|
+
* **extension:** improve context usage bar visualization ([d69c270](https://github.com/jgentes/mcpflare/commit/d69c270519a92ca1b0eecac6497ecb264228be24))
|
|
15
|
+
* **extension:** integrate MCP Guard with IDE config manipulation ([e44d0df](https://github.com/jgentes/mcpflare/commit/e44d0df00118a6287b76447d0cc2e8cf6b35352b))
|
|
16
|
+
* implement network allowlist enforcement for Worker isolation ([d92eef5](https://github.com/jgentes/mcpflare/commit/d92eef55b4822682552c899d88f9c4f50416d3ee))
|
|
17
|
+
* implement network allowlist with FetchProxy Service Binding ([f923a26](https://github.com/jgentes/mcpflare/commit/f923a26cb68afff0caecf8bfdafa7d8fd243b0fc))
|
|
18
|
+
* **vscode-extension:** Add MCP config management and cache invalidation ([d0c50be](https://github.com/jgentes/mcpflare/commit/d0c50be3ed2086417c88fe82438ea60b9f055168))
|
|
19
|
+
* **vscode:** add context window usage visualization panel ([5caeeea](https://github.com/jgentes/mcpflare/commit/5caeeea89d8fc1312a5b42cafeff99f94c7cb7bd))
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* build before tests in release workflow ([16199d1](https://github.com/jgentes/mcpflare/commit/16199d1609d0cd741f6ea819697738ad198812bf))
|
|
24
|
+
* clear per-MCP schema cache and align webview enabled state ([1b1bbf1](https://github.com/jgentes/mcpflare/commit/1b1bbf19097af61520367f0c99a199ca98089dba))
|
|
25
|
+
* **cli,server:** improve type safety and code formatting ([3050e46](https://github.com/jgentes/mcpflare/commit/3050e46d80ece833787883b01bd509bddda2fa22))
|
|
26
|
+
* configure release workflow for OIDC trusted publishing ([e6442e9](https://github.com/jgentes/mcpflare/commit/e6442e9dcbe0c4af106364f86f63f364dded8b0c))
|
|
27
|
+
* improve MCP assessment and context usage display ([2944365](https://github.com/jgentes/mcpflare/commit/29443659dd02a3f8f3d4969371c3471ef62f4082))
|
|
28
|
+
* improve URL-based MCP caching and connection handling ([47471c2](https://github.com/jgentes/mcpflare/commit/47471c255ff4db9d178458a5967929202ab7e982))
|
|
29
|
+
* prevent command injection in killProcessTree function ([5a8fc7a](https://github.com/jgentes/mcpflare/commit/5a8fc7a65b9fe907589e58fb830b7a8ad1631060))
|
|
30
|
+
* prevent URL-based MCPs from using stale zero-tool cache ([f8860c1](https://github.com/jgentes/mcpflare/commit/f8860c10ec12efc4250a85e2a8922b827ed897cb))
|
|
31
|
+
* resolve CI failures in lint and eval tests ([daa1167](https://github.com/jgentes/mcpflare/commit/daa11674bb2b3c5305fefaad24d431a7c158cd62))
|
|
32
|
+
* resolve peer dependency conflicts for CI and docs builds ([c65bd4e](https://github.com/jgentes/mcpflare/commit/c65bd4ec633413e89adefccb5aed7721783fca9c))
|
|
33
|
+
* resolve test failures in config-manager and webview-provider ([6c47700](https://github.com/jgentes/mcpflare/commit/6c47700fab8cab56692565d7546cc07fb8770747))
|
|
34
|
+
* resolve TypeScript module resolution and type errors ([cd7f477](https://github.com/jgentes/mcpflare/commit/cd7f477f019998b6b27eb271a512e2ed7152864d))
|
|
35
|
+
* **server:** align worker network policy with isolation config ([10539f0](https://github.com/jgentes/mcpflare/commit/10539f01aababd08162da3c0761c17d946c63eef))
|
|
36
|
+
* update homepage URL to https://mcpflare.org ([eb70260](https://github.com/jgentes/mcpflare/commit/eb702607052804ce867833ee924c179e5a76e074))
|
|
37
|
+
* **vscode:** prevent MCP card collapse on save and eliminate UI flashing ([96da0ee](https://github.com/jgentes/mcpflare/commit/96da0eeac42ee3973024dd1446059609f224225d))
|
|
38
|
+
|
|
39
|
+
All notable changes to this project will be documented in this file.
|
|
40
|
+
|
|
41
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
42
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
43
|
+
|
|
44
|
+
## [0.2.0] - 2024-12-13
|
|
45
|
+
|
|
46
|
+
### Added
|
|
47
|
+
- Initial release of MCPflare
|
|
48
|
+
- Zero-trust execution environment using Cloudflare Workers isolates
|
|
49
|
+
- Code mode execution for massive token savings (up to 98% reduction)
|
|
50
|
+
- Interactive CLI for testing MCP servers
|
|
51
|
+
- MCP server implementation with transparent proxy mode
|
|
52
|
+
- Automatic MCP discovery from IDE configurations (Cursor, Claude Code, GitHub Copilot)
|
|
53
|
+
- Security features: V8 isolate sandboxing, network isolation, code validation
|
|
54
|
+
- Service Bindings architecture for secure MCP tool access
|
|
55
|
+
- Schema caching for faster MCP loading
|
|
56
|
+
- Comprehensive test suite (unit, integration, security tests)
|
|
57
|
+
- VS Code extension for MCP management
|
|
58
|
+
- Documentation: README, CLAUDE.md, SECURITY_ANALYSIS.md
|
|
59
|
+
|
|
60
|
+
### Security
|
|
61
|
+
- Complete network isolation for sandboxed code execution
|
|
62
|
+
- Pre-execution code validation blocking dangerous patterns
|
|
63
|
+
- Disposable execution environments preventing state leakage
|
|
64
|
+
- Binding-based access control for explicit permissions
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
**Note**: This changelog will be automatically updated by release-it based on conventional commits.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 James Gentes
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
# MCPflare
|
|
2
|
+
|
|
3
|
+
> Use local MCP servers securely with zero-trust isolation while reducing context window token usage by up to 98%.
|
|
4
|
+
|
|
5
|
+
*⚡ This implementation is based on [Code execution with MCP: Building more efficient agents](https://www.anthropic.com/engineering/code-execution-with-mcp) by Anthropic. It uses [Wrangler](https://www.npmjs.com/package/wrangler) for local MCP isolation using [Dynamic Worker Loaders](https://developers.cloudflare.com/workers/runtime-apis/bindings/worker-loader/) as described in [Code Mode: the better way to use MCP](https://blog.cloudflare.com/code-mode/) by Cloudflare.*
|
|
6
|
+
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
[](https://www.typescriptlang.org/)
|
|
9
|
+
[](https://nodejs.org/)
|
|
10
|
+
|
|
11
|
+
## 🛡️ How It Works: A Simple Example
|
|
12
|
+
|
|
13
|
+

|
|
14
|
+
|
|
15
|
+
### Real Attack Example
|
|
16
|
+
|
|
17
|
+
**Scenario:** Malicious prompt tries to steal your secrets
|
|
18
|
+
|
|
19
|
+
**Traditional MCP:**
|
|
20
|
+
```
|
|
21
|
+
User: "Show me all environment variables"
|
|
22
|
+
LLM: Calls read_env() tool
|
|
23
|
+
Result: ⚠️ SECRET_TOKEN=xxxxxxxxxxxx exposed
|
|
24
|
+
LLM: Exfiltrate SECRET_TOKEN via POST to "https://attacker.com/steal"
|
|
25
|
+
Result: ⚠️ Fetch request succeeds
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**With MCPflare:**
|
|
29
|
+
```
|
|
30
|
+
User: "Show me all environment variables"
|
|
31
|
+
LLM: Writes code: console.log(process.env)
|
|
32
|
+
Result: ✅ ReferenceError: process is not defined
|
|
33
|
+
Your secret stays safe
|
|
34
|
+
LLM: Exfiltrate SECRET_TOKEN via POST to "https://attacker.com/steal"
|
|
35
|
+
Result: ✅ Network access blocked
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## 🔒 Security: Zero-Trust Execution
|
|
39
|
+
|
|
40
|
+
MCPflare runs all code in local Cloudflare Worker isolates with **zero access** to your filesystem, environment variables, network, or system, which protects against data exfiltration, credential theft, filesystem access, arbitrary code execution, process manipulation, SSRF attacks, code injection, supply chain attacks, and more.
|
|
41
|
+
|
|
42
|
+
**Three layers of protection:**
|
|
43
|
+
1. **V8 Isolate Sandboxing** - Complete process isolation
|
|
44
|
+
2. **Network Isolation** - No outbound network access, only MCP bindings can communicate
|
|
45
|
+
3. **Code Validation** - Blocks dangerous patterns before execution
|
|
46
|
+
|
|
47
|
+
📖 **[Read the security analysis](https://jgentes.github.io/mcpflare/docs/security)** for attack vector details and defense-in-depth architecture.
|
|
48
|
+
|
|
49
|
+
## ⚡ Efficiency: Code Mode Execution
|
|
50
|
+
|
|
51
|
+
Traditional MCP tool calling wastes your context window. MCPflare uses **code mode** to reduce token usage by up to 98%.
|
|
52
|
+
|
|
53
|
+
### Example: Generating a Jira Sprint Report
|
|
54
|
+
|
|
55
|
+
**Traditional approach:** The LLM calls tools step-by-step, and every result flows through the context window:
|
|
56
|
+
|
|
57
|
+
1. Fetch 200 sprint tickets → **25,000 tokens** loaded into context
|
|
58
|
+
2. LLM reads all tickets to count completed vs blocked
|
|
59
|
+
3. Fetch time tracking data → **5,000 tokens** more
|
|
60
|
+
4. Generate summary → **300 tokens**
|
|
61
|
+
|
|
62
|
+
**Total:** 30,300 tokens just to count tickets and generate a simple report.
|
|
63
|
+
|
|
64
|
+
**With MCPflare:** The code runs in a secure sandbox, processes all 200 tickets, and only sends back the final summary. The LLM never has to read the individual tickets:
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
// Fetch tickets, filter and count in code, return only the summary
|
|
68
|
+
import * as jira from './servers/jira';
|
|
69
|
+
|
|
70
|
+
const tickets = await jira.getSprintTickets({ sprintId: '123' });
|
|
71
|
+
const stats = {
|
|
72
|
+
completed: tickets.filter(t => t.status === 'Done').length,
|
|
73
|
+
blocked: tickets.filter(t => t.labels.includes('blocked')).length,
|
|
74
|
+
total: tickets.length
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
console.log(`Sprint Summary: ${stats.completed}/${stats.total} completed, ${stats.blocked} blocked`);
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Result:** Instead of 30,300 tokens, you use ~750 tokens. **97.5% reduction.**
|
|
81
|
+
|
|
82
|
+
**Benefits:**
|
|
83
|
+
- 📉 **Up to 98% reduction** in token usage
|
|
84
|
+
- 🚀 **60x more tasks** in the same context window
|
|
85
|
+
- 💰 **Massive cost savings** on LLM API calls
|
|
86
|
+
- ⚡ **No round-trips** for intermediate results
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
## 🏃 Quick Start
|
|
90
|
+
|
|
91
|
+
**Requires:** [Node.js 20+](https://nodejs.org/) installed
|
|
92
|
+
|
|
93
|
+
### Installation Steps
|
|
94
|
+
|
|
95
|
+
1. **Add MCPflare to your IDE config** (Cursor, Claude Code, or GitHub Copilot):
|
|
96
|
+
|
|
97
|
+
[](https://cursor.com/en/install-mcp?name=mcpflare&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIm1jcGZsYXJlIl19)
|
|
98
|
+
|
|
99
|
+
Or manually add to your IDE's MCP configuration:
|
|
100
|
+
```json
|
|
101
|
+
{
|
|
102
|
+
"mcpServers": {
|
|
103
|
+
"mcpflare": {
|
|
104
|
+
"command": "npx",
|
|
105
|
+
"args": ["-y", "mcpflare"]
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
2. **Disable existing MCPs** (recommended):
|
|
112
|
+
|
|
113
|
+
To maximize efficiency and security, disable any existing MCPs in your IDE configuration. This prevents the IDE from loading all their tools into the context window unnecessarily, which is one of MCPflare's key benefits - you only load and use the tools you actually need.
|
|
114
|
+
|
|
115
|
+
**Why disable?**
|
|
116
|
+
- ⚡ **Efficiency**: Without disabling, your IDE loads all MCP tools into the context window, wasting tokens. MCPflare only loads tools lazily when you actually use them (via `call_mcp` or namespaced tool calls).
|
|
117
|
+
- 🔒 **Security**: Ensures all tool calls route through MCPflare's secure isolation instead of being called directly.
|
|
118
|
+
|
|
119
|
+
**How to disable:**
|
|
120
|
+
Ask your LLM: "Disable all MCPs except mcpflare in my IDE configuration"
|
|
121
|
+
|
|
122
|
+
This uses MCPflare's `guard` tool to move MCPs to a special `_mcpflare_disabled` section in your config file. MCPflare can still discover and use these disabled MCPs through its secure isolation layer.
|
|
123
|
+
|
|
124
|
+
> ⚠️ **Important**: Do NOT manually comment out or remove MCP entries from your config file. If you do, MCPflare won't be able to discover them. MCPflare needs the MCP configurations to remain in the file (either active or in the `_mcpflare_disabled` section) to route tool calls through secure isolation.
|
|
125
|
+
|
|
126
|
+
3. **Restart your IDE** for changes to take effect.
|
|
127
|
+
|
|
128
|
+
4. **That's it!** MCPflare automatically:
|
|
129
|
+
- Discovers all other MCPs configured in your IDE (even disabled ones)
|
|
130
|
+
- Routes all tool calls through secure Worker isolation
|
|
131
|
+
- Lazy-loads MCPs when their tools are actually used (via `call_mcp` or namespaced tool calls)
|
|
132
|
+
|
|
133
|
+
**No additional setup needed!** MCPflare uses transparent proxy mode by default - all your existing MCPs are automatically guarded without any config changes (once they're disabled).
|
|
134
|
+
|
|
135
|
+
### How Transparent Proxy Mode Works
|
|
136
|
+
|
|
137
|
+
MCPflare automatically:
|
|
138
|
+
1. **Discovers** all MCPs configured in your IDE (Cursor, Claude Code, or GitHub Copilot)
|
|
139
|
+
2. **Lazy-loads** tool schemas only when tools are actually called (not upfront - this keeps your context window efficient)
|
|
140
|
+
3. **Routes** all tool calls through secure Worker isolation
|
|
141
|
+
4. **Auto-loads** MCPs when their tools are first used
|
|
142
|
+
|
|
143
|
+
**Example:** If you have `github` MCP configured, MCPflare will:
|
|
144
|
+
- When the LLM calls `github::search_repositories`, MCPflare automatically loads the GitHub MCP schema and executes the call in isolation
|
|
145
|
+
- All results are returned transparently - the LLM doesn't need to know about the isolation layer
|
|
146
|
+
- Tool schemas are cached after first use for faster subsequent calls
|
|
147
|
+
|
|
148
|
+
This means **all MCP tool calls automatically go through MCPflare** - no config changes needed!
|
|
149
|
+
|
|
150
|
+
You'll see a prompt like this:
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
╔═══════════════════════════════════════════════════════════╗
|
|
154
|
+
║ MCPflare - Interactive CLI ║
|
|
155
|
+
╚═══════════════════════════════════════════════════════════╝
|
|
156
|
+
|
|
157
|
+
Type "help" for available commands.
|
|
158
|
+
Type "exit" to quit.
|
|
159
|
+
|
|
160
|
+
mcpflare>
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Basic Usage
|
|
164
|
+
|
|
165
|
+
1. **Load an MCP server:**
|
|
166
|
+
```
|
|
167
|
+
load
|
|
168
|
+
```
|
|
169
|
+
Enter the MCP name, command (e.g., `npx`), args, and environment variables.
|
|
170
|
+
|
|
171
|
+
2. **Get the TypeScript API schema:**
|
|
172
|
+
```
|
|
173
|
+
schema
|
|
174
|
+
```
|
|
175
|
+
Enter the MCP ID to see available tools as TypeScript APIs.
|
|
176
|
+
|
|
177
|
+
3. **Execute code:**
|
|
178
|
+
```
|
|
179
|
+
execute
|
|
180
|
+
```
|
|
181
|
+
Enter the MCP ID and TypeScript code to run in the isolated Worker.
|
|
182
|
+
|
|
183
|
+
4. **List loaded MCPs:**
|
|
184
|
+
```
|
|
185
|
+
list
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## 🧪 Testing with GitHub MCP
|
|
189
|
+
|
|
190
|
+
Follow these steps to test the system with GitHub MCP:
|
|
191
|
+
|
|
192
|
+
### 1. Start the CLI
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
npm run cli
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### 2. Load the GitHub MCP Server
|
|
199
|
+
|
|
200
|
+
At the `mcpflare>` prompt, type:
|
|
201
|
+
|
|
202
|
+
```
|
|
203
|
+
load
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
You'll be prompted for information. Enter:
|
|
207
|
+
|
|
208
|
+
- **MCP name**: `github` (or any name you like)
|
|
209
|
+
- **Command**: `npx`
|
|
210
|
+
- **Args**: `-y,@modelcontextprotocol/server-github` (comma-separated)
|
|
211
|
+
- **Environment variables**: `{"GITHUB_PERSONAL_ACCESS_TOKEN":"ghp_your_token_here"}` (as JSON)
|
|
212
|
+
|
|
213
|
+
**Example interaction:**
|
|
214
|
+
|
|
215
|
+
```
|
|
216
|
+
mcpflare> load
|
|
217
|
+
MCP name: github
|
|
218
|
+
Command (e.g., npx): npx
|
|
219
|
+
Args (comma-separated, or press Enter for none): -y,@modelcontextprotocol/server-github
|
|
220
|
+
Environment variables as JSON (or press Enter for none): {"GITHUB_PERSONAL_ACCESS_TOKEN":"ghp_your_actual_token"}
|
|
221
|
+
|
|
222
|
+
Loading MCP server...
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### 3. Check What Was Loaded
|
|
226
|
+
|
|
227
|
+
Type:
|
|
228
|
+
|
|
229
|
+
```
|
|
230
|
+
list
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
You should see your loaded MCP server with its ID, status, and available tools.
|
|
234
|
+
|
|
235
|
+
### 4. Get the TypeScript API Schema
|
|
236
|
+
|
|
237
|
+
Type:
|
|
238
|
+
|
|
239
|
+
```
|
|
240
|
+
schema
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
Enter the MCP ID from the previous step. You'll see the TypeScript API definitions that were generated from the MCP tools.
|
|
244
|
+
|
|
245
|
+
### 5. Execute Some Code
|
|
246
|
+
|
|
247
|
+
Type:
|
|
248
|
+
|
|
249
|
+
```
|
|
250
|
+
execute
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
You'll be prompted:
|
|
254
|
+
- **MCP ID**: Enter the ID from step 3
|
|
255
|
+
- **TypeScript code**: Enter your code (end with a blank line)
|
|
256
|
+
- **Timeout**: Press Enter for default (30000ms)
|
|
257
|
+
|
|
258
|
+
**Example code to test:**
|
|
259
|
+
|
|
260
|
+
```typescript
|
|
261
|
+
// Simple test
|
|
262
|
+
console.log('Hello from Worker isolate!');
|
|
263
|
+
const result = { message: 'Test successful', timestamp: Date.now() };
|
|
264
|
+
console.log(JSON.stringify(result));
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### 6. View Metrics
|
|
268
|
+
|
|
269
|
+
Type:
|
|
270
|
+
|
|
271
|
+
```
|
|
272
|
+
metrics
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
This shows performance metrics including:
|
|
276
|
+
- Total executions
|
|
277
|
+
- Success rate
|
|
278
|
+
- Average execution time
|
|
279
|
+
- Estimated tokens saved
|
|
280
|
+
|
|
281
|
+
### 7. Clean Up
|
|
282
|
+
|
|
283
|
+
When done testing, unload the MCP:
|
|
284
|
+
|
|
285
|
+
```
|
|
286
|
+
unload
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Enter the MCP ID to clean up resources.
|
|
290
|
+
|
|
291
|
+
## 📖 Available CLI Commands
|
|
292
|
+
|
|
293
|
+
| Command | Description |
|
|
294
|
+
|---------|-------------|
|
|
295
|
+
| `load` | Load an MCP server into an isolated Worker |
|
|
296
|
+
| `execute` | Execute TypeScript code against a loaded MCP |
|
|
297
|
+
| `test` | Interactively test MCP tools (select tool, enter args, execute via Wrangler) |
|
|
298
|
+
| `test-direct` | Test MCP directly without Wrangler/Worker isolation |
|
|
299
|
+
| `list` | List all loaded MCP servers |
|
|
300
|
+
| `saved` | List all saved MCP configurations |
|
|
301
|
+
| `schema` | Get TypeScript API schema for an MCP |
|
|
302
|
+
| `unload` | Unload an MCP server and clean up |
|
|
303
|
+
| `conflicts` | Check for IDE MCP configuration conflicts |
|
|
304
|
+
| `metrics` | Show performance metrics |
|
|
305
|
+
| `help` | Show help message |
|
|
306
|
+
| `exit` | Exit the CLI |
|
|
307
|
+
|
|
308
|
+
## 🔧 Using as an MCP Server (for AI Agents)
|
|
309
|
+
|
|
310
|
+
Start the MCP server:
|
|
311
|
+
|
|
312
|
+
```bash
|
|
313
|
+
npm run dev
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
Configure your AI agent (Claude Desktop, Cursor IDE, etc.):
|
|
317
|
+
|
|
318
|
+
```json
|
|
319
|
+
{
|
|
320
|
+
"mcpServers": {
|
|
321
|
+
"mcpflare": {
|
|
322
|
+
"command": "node",
|
|
323
|
+
"args": ["/path/to/mcpflare/dist/server/index.js"]
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
**Available MCP Tools:**
|
|
330
|
+
|
|
331
|
+
**Transparent Proxy Tools** (lazy-loaded from configured MCPs):
|
|
332
|
+
- Tools from your configured MCPs are available with namespaced names (e.g., `github::search_repositories`)
|
|
333
|
+
- Schemas are loaded on-demand when tools are called, keeping your context window efficient
|
|
334
|
+
- All tool calls are routed through secure isolation
|
|
335
|
+
|
|
336
|
+
**MCP Prompts** (slash commands):
|
|
337
|
+
- Prompts from your configured MCPs appear as slash commands (e.g., `/mcpflare/github:AssignCodingAgent`)
|
|
338
|
+
- Prompts are read-only message templates, so they're directly proxied without worker isolation
|
|
339
|
+
- All prompts are transparently aggregated and namespaced for easy discovery
|
|
340
|
+
|
|
341
|
+
**MCPflare Management Tools:**
|
|
342
|
+
- `call_mcp` - Call MCP tools by running TypeScript code in a secure sandbox (auto-connects MCPs from IDE config if needed)
|
|
343
|
+
- `guard` - Guard MCP servers by routing them through MCPflare's secure isolation
|
|
344
|
+
- `search_mcp_tools` - Discover which MCPs are configured in your IDE. Shows all configured MCPs (including guarded) with their status and available tools.
|
|
345
|
+
- `connect` - Manually connect to an MCP server (usually not needed - transparent proxy auto-connects)
|
|
346
|
+
- `list_available_mcps` - List all currently connected MCP servers (runtime state)
|
|
347
|
+
- `get_mcp_by_name` - Find a connected MCP server by name (more efficient than searching list_available_mcps)
|
|
348
|
+
- `get_mcp_schema` - Get TypeScript API definition for a connected MCP
|
|
349
|
+
- `disconnect` - Disconnect from an MCP server
|
|
350
|
+
- `import_configs` - Import MCP configurations from IDE config files
|
|
351
|
+
- `get_metrics` - Get performance metrics
|
|
352
|
+
|
|
353
|
+
## 📜 License
|
|
354
|
+
|
|
355
|
+
MIT License - see [LICENSE](./LICENSE) file for details.
|
|
356
|
+
|
|
357
|
+
## 🙏 Acknowledgments
|
|
358
|
+
|
|
359
|
+
- [Anthropic](https://www.anthropic.com/) for the Model Context Protocol
|
|
360
|
+
- [Cloudflare](https://www.cloudflare.com/) for Workers and the Worker Loader API
|
|
361
|
+
- The MCP community for building amazing MCP servers
|
|
362
|
+
|
|
363
|
+
## 🔐 Repository Security (GitHub Advanced Security)
|
|
364
|
+
|
|
365
|
+
We take security seriously. This repository has GitHub Advanced Security features enabled, including **CodeQL code scanning**, **Dependabot alerts**, **dependency graph/submission**, and **secret scanning + push protection**. We also enable **private vulnerability reporting** so issues can be disclosed responsibly.
|
|
366
|
+
|
|
367
|
+
If you believe you’ve found a security issue, please see [`SECURITY.md`](./SECURITY.md) for reporting instructions.
|
|
368
|
+
|
|
369
|
+
---
|
|
370
|
+
|
|
371
|
+
**Ready to get started?** Run `npm install` and then `npm run cli` to begin! 🚀
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":""}
|