mcp-squared 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,23 +1,208 @@
1
1
  # MCP²: Mercury Control Plane for MCP
2
2
 
3
- MCP² (Mercury Control Plane) is a local-first meta-server and proxy for the Model Context Protocol (MCP). It addresses the problem of tool context bloat and schema token overhead by enabling dynamic, progressive disclosure of tools to LLMs. Instead of flooding the model context with every available tool schema, MCP² exposes a stable, minimal surface area for tool discovery and execution.
3
+ MCP² (Mercury Control Plane) is a local-first meta-server and proxy for the Model Context Protocol (MCP). It addresses tool context bloat by enabling dynamic, progressive disclosure of tools to LLMs. Instead of flooding the model context with every available tool schema, MCP² exposes a stable, minimal surface area for tool discovery and execution.
4
4
 
5
5
  ## Status
6
- **Inception / Pre-alpha**
6
+ **Alpha (v0.1.x)** - Core functionality is implemented and tested; CLI and config details may evolve.
7
7
 
8
- ## High-Level Approach
9
- MCP² acts as an intelligent middleware between your MCP clients (IDEs, agents) and upstream MCP servers. It provides:
10
- - `find_tools`: A semantic search interface to locate relevant capabilities.
11
- - `describe_tools`: On-demand retrieval of full schemas for selected tools.
12
- - `execute`: A passthrough execution layer with optional result caching and summarization.
8
+ ## Install & Run
9
+
10
+ MCP² is published on npm as `mcp-squared`. The CLI runs on Bun (even when installed via npm), so you'll need Bun installed on your machine.
11
+
12
+ ### Prerequisite: Bun
13
+
14
+ Install Bun (>= 1.0.0): https://bun.sh
15
+
16
+ ### Run without installing (recommended)
17
+
18
+ ```bash
19
+ bunx mcp-squared --help
20
+ bunx mcp-squared
21
+ ```
22
+
23
+ ### Run via npm / npx
24
+
25
+ ```bash
26
+ npx mcp-squared --help
27
+ npm exec --yes mcp-squared -- --help
28
+ ```
29
+
30
+ ### Install globally
31
+
32
+ ```bash
33
+ npm i -g mcp-squared
34
+ mcp-squared --help
35
+
36
+ # or
37
+ bun add -g mcp-squared
38
+ mcp-squared --help
39
+ ```
40
+
41
+ ### Run from source
42
+
43
+ ```bash
44
+ # Clone the repository
45
+ git clone https://github.com/aditzel/mcp-squared
46
+ cd mcp-squared
47
+
48
+ # Install dependencies
49
+ bun install
50
+
51
+ # Run in development mode
52
+ bun run dev
53
+
54
+ # Build for production
55
+ bun run build
56
+
57
+ # Run tests
58
+ bun test
59
+
60
+ # Dependency audit
61
+ bun run audit
62
+ ```
63
+
64
+ ### Standalone Executable (Experimental)
65
+
66
+ Build a single-file executable with Bun:
67
+
68
+ ```bash
69
+ bun run build:compile
70
+ ```
71
+
72
+ Run the compile validation matrix (darwin/linux/windows target support, size checks, standalone smoke test, embeddings probe):
73
+
74
+ ```bash
75
+ bun run build:compile:matrix
76
+ ```
77
+
78
+ Current findings and known blockers are tracked in `docs/STANDALONE-COMPILE.md`.
79
+
80
+ ## CLI Commands (Common)
81
+
82
+ ```bash
83
+ mcp-squared # Auto: daemon (TTY) or proxy (piped stdio)
84
+ mcp-squared --stdio # Start MCP server (stdio mode)
85
+ mcp-squared daemon # Start shared daemon (multi-client backend)
86
+ mcp-squared proxy # Start stdio proxy to the shared daemon
87
+ mcp-squared config # Launch configuration TUI
88
+ mcp-squared test [upstream] # Test upstream server connections
89
+ mcp-squared auth <upstream> # OAuth auth for SSE/HTTP upstreams
90
+ mcp-squared import # Import MCP configs from other tools
91
+ mcp-squared install # Install MCP² into other MCP clients
92
+ mcp-squared monitor # Launch server monitor TUI
93
+ mcp-squared --help # Full command reference
94
+ ```
95
+
96
+ ## Shared Daemon Mode (Optional)
97
+
98
+ Shared daemon mode keeps a single MCP² backend alive and lets multiple stdio clients connect through lightweight proxies. This reduces duplicated upstream connections and indexing work when many tools run in parallel.
99
+
100
+ Auto mode chooses `daemon` when running in a TTY and `proxy` when stdin/stdout are piped (as MCP clients do).
101
+
102
+ ```bash
103
+ mcp-squared daemon # Start the shared backend
104
+ mcp-squared proxy # Run a stdio proxy that connects to the daemon
105
+ mcp-squared daemon --daemon-socket=tcp://127.0.0.1:45000
106
+ mcp-squared proxy --daemon-socket=tcp://127.0.0.1:45000
107
+ ```
108
+
109
+ Security notes for TCP daemon endpoints:
110
+ - TCP daemon bind host is restricted to loopback (`localhost`, `127.0.0.1`, `::1`).
111
+ - Optional shared-secret handshake is available with `--daemon-secret=<secret>` (or `MCP_SQUARED_DAEMON_SECRET`).
112
+
113
+ When installing into supported clients, you can register the proxy automatically:
114
+
115
+ ```bash
116
+ mcp-squared install --proxy
117
+ mcp-squared install --stdio
118
+ ```
119
+
120
+ ## Configuration
121
+
122
+ Config discovery order:
123
+ 1. `MCP_SQUARED_CONFIG` environment variable
124
+ 2. Project-local `mcp-squared.toml` or `.mcp-squared/config.toml`
125
+ 3. User-level `~/.config/mcp-squared/config.toml` (or `%APPDATA%/mcp-squared/config.toml` on Windows)
126
+
127
+ Minimal example:
128
+
129
+ ```toml
130
+ schemaVersion = 1
131
+
132
+ [upstreams.local]
133
+ transport = "stdio"
134
+ [upstreams.local.stdio]
135
+ command = "mcp-server-local"
136
+ args = []
137
+
138
+ [upstreams.remote]
139
+ transport = "sse"
140
+ [upstreams.remote.sse]
141
+ url = "https://example.com/mcp"
142
+ auth = true
143
+ ```
144
+
145
+ Security policies (allow/block/confirm) live under `security.tools`. Confirmation flows return a short-lived token that must be provided to `execute` to proceed. OAuth tokens for SSE upstreams are stored under `~/.config/mcp-squared/tokens/<upstream>.json`.
146
+
147
+ ## Tool API (Meta-Tools)
148
+
149
+ MCP² exposes these tools to MCP clients:
150
+ - `find_tools` - Search tools across upstream servers
151
+ - `describe_tools` - Fetch full JSON schemas for selected tools
152
+ - `execute` - Call an upstream tool with policy enforcement
153
+ - `list_namespaces` - List upstream namespaces (optionally with tool names)
154
+ - `clear_selection_cache` - Reset co-occurrence based suggestions
155
+
156
+ ## Search Modes
157
+
158
+ `find_tools` supports three search modes:
159
+ - `fast` (default): SQLite FTS5 full-text search
160
+ - `semantic`: Embedding similarity search (falls back to `fast` if embeddings are missing)
161
+ - `hybrid`: FTS5 + embedding rerank (falls back to `fast` if embeddings are missing)
162
+
163
+ > **Note:** Semantic and hybrid modes load a local embedding model (BGE-small via Transformers.js/WASM). First load downloads ~33MB and adds ~294MB RSS. These modes are optional - `fast` mode (default) has no such overhead.
164
+
165
+ Embeddings are generated locally using Transformers.js (BGE-small). They are optional and can be generated programmatically via the retriever API.
166
+
167
+ ## Supported MCP Clients (Import/Install)
168
+
169
+ MCP² can import or install MCP server configs for:
170
+ `claude-code`, `claude-desktop`, `cursor`, `windsurf`, `vscode`, `cline`, `roo-code`, `kilo-code`, `gemini-cli`, `zed`, `jetbrains`, `factory`, `opencode`, `qwen-code`, `trae`, `antigravity`, `warp` (import via explicit path), and `codex`.
171
+
172
+ ## Key Features
173
+ - Multi-upstream support (stdio + SSE/HTTP)
174
+ - OAuth 2.0 dynamic client registration for SSE upstreams
175
+ - Hybrid search with optional local embeddings (FTS5 + Transformers.js)
176
+ - Detail levels (L0/L1/L2) for progressive schema disclosure
177
+ - Selection caching with co-occurrence suggestions
178
+ - Background index refresh with change detection
179
+ - Security policies (allow/block/confirm) with confirmation tokens
180
+ - Local-first architecture (SQLite index)
181
+ - TUI interfaces for configuration and monitoring
13
182
 
14
183
  ## Non-Goals
15
184
  - Not a hosted SaaS platform (local-first).
16
185
  - Not a replacement for MCP clients (it serves them).
17
186
  - Not shipping language runtimes or SDKs at this stage.
18
187
 
188
+ ## Architecture
189
+
190
+ MCP² is built with Bun and TypeScript, leveraging:
191
+ - @modelcontextprotocol/sdk for MCP communication
192
+ - @huggingface/transformers for embeddings generation
193
+ - @opentui/core for the terminal user interface
194
+ - Zod for validation
195
+
196
+ See `docs/ARCHITECTURE.md` for a full architecture breakdown.
197
+
19
198
  ## Contributing
20
- We welcome contributions! Please see [CONTRIBUTING.md](.github/CONTRIBUTING.md) for details on how to get started.
199
+
200
+ We welcome contributions! Please see `.github/CONTRIBUTING.md` for details on how to get started.
201
+
202
+ ## Releasing
203
+
204
+ Maintainers can follow `docs/RELEASING.md` for the npm release checklist and `docs/DEPENDENCY_MAINTENANCE.md` for dependency cadence and exception handling.
21
205
 
22
206
  ## License
207
+
23
208
  Apache-2.0