@miller-tech/uap 1.40.0 → 1.41.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 +109 -642
- package/dist/.tsbuildinfo +1 -1
- package/dist/cli/deliver-defaults.d.ts +23 -0
- package/dist/cli/deliver-defaults.d.ts.map +1 -0
- package/dist/cli/deliver-defaults.js +121 -0
- package/dist/cli/deliver-defaults.js.map +1 -0
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +29 -0
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/setup.d.ts.map +1 -1
- package/dist/cli/setup.js +19 -0
- package/dist/cli/setup.js.map +1 -1
- package/dist/policies/policy-tools.d.ts +7 -0
- package/dist/policies/policy-tools.d.ts.map +1 -1
- package/dist/policies/policy-tools.js +24 -2
- package/dist/policies/policy-tools.js.map +1 -1
- package/docs/INDEX.md +48 -286
- package/docs/architecture/OVERVIEW.md +328 -0
- package/docs/architecture/PROTOCOL.md +204 -0
- package/docs/benchmarks/README.md +17 -192
- package/docs/getting-started/CONFIGURATION.md +237 -0
- package/docs/getting-started/INSTALLATION.md +125 -0
- package/docs/getting-started/QUICKSTART.md +115 -0
- package/docs/guides/COORDINATION.md +162 -0
- package/docs/guides/DELIVER.md +115 -0
- package/docs/guides/DEPLOY_BATCHING.md +212 -0
- package/docs/guides/DROIDS_AND_SKILLS.md +202 -0
- package/docs/guides/LOCAL_MODELS.md +148 -0
- package/docs/guides/MCP_ROUTER.md +195 -0
- package/docs/guides/MEMORY.md +235 -0
- package/docs/guides/MULTI_MODEL.md +223 -0
- package/docs/guides/POLICIES.md +190 -0
- package/docs/guides/WORKTREE_WORKFLOW.md +185 -0
- package/docs/integrations/MCP_ROUTER.md +147 -0
- package/docs/integrations/RTK.md +102 -0
- package/docs/reference/API.md +485 -0
- package/docs/reference/CLI.md +719 -0
- package/docs/reference/CONFIGURATION.md +90 -193
- package/docs/reference/DATABASE_SCHEMA.md +110 -344
- package/docs/reference/FEATURES.md +176 -472
- package/docs/reference/PATTERNS.md +102 -0
- package/docs/reference/PLATFORMS.md +83 -0
- package/package.json +3 -1
- package/src/policies/enforcers/7ebbc721-7540-4e9f-879a-770e0213a09b_architecture_review.py +101 -0
- package/src/policies/enforcers/__pycache__/_common.cpython-312.pyc +0 -0
- package/src/policies/enforcers/_common.py +100 -0
- package/src/policies/enforcers/artifact_hygiene.py +52 -0
- package/src/policies/enforcers/cluster_routing.py +63 -0
- package/src/policies/enforcers/codebase_read_before_plan.py +52 -0
- package/src/policies/enforcers/coord_overlap.py +81 -0
- package/src/policies/enforcers/delivery_enforcement.py +97 -0
- package/src/policies/enforcers/doc_live_over_report.py +50 -0
- package/src/policies/enforcers/expert_review_required.py +135 -0
- package/src/policies/enforcers/iac_parity.py +53 -0
- package/src/policies/enforcers/mcp_router_first.py +37 -0
- package/src/policies/enforcers/memory_before_plan.py +61 -0
- package/src/policies/enforcers/parallel_reads.py +50 -0
- package/src/policies/enforcers/rtk_wrap.py +44 -0
- package/src/policies/enforcers/schema_diff_gate.py +80 -0
- package/src/policies/enforcers/session_memory_write.py +52 -0
- package/src/policies/enforcers/task_required.py +131 -0
- package/src/policies/enforcers/test_gate.py +58 -0
- package/src/policies/enforcers/validate_plan_before_build.py +75 -0
- package/src/policies/enforcers/worktree_required.py +57 -0
- package/src/policies/schemas/policies/architecture-review.md +51 -0
- package/src/policies/schemas/policies/artifact-hygiene.md +29 -0
- package/src/policies/schemas/policies/cluster-routing.md +31 -0
- package/src/policies/schemas/policies/codebase-read-before-plan.md +30 -0
- package/src/policies/schemas/policies/coord-overlap.md +24 -0
- package/src/policies/schemas/policies/delivery-enforcement.md +45 -0
- package/src/policies/schemas/policies/doc-live-over-report.md +32 -0
- package/src/policies/schemas/policies/expert-review-required.md +60 -0
- package/src/policies/schemas/policies/iac-parity.md +31 -0
- package/src/policies/schemas/policies/mandatory-testing-deployment.md +147 -0
- package/src/policies/schemas/policies/mcp-router-first.md +24 -0
- package/src/policies/schemas/policies/memory-before-plan.md +24 -0
- package/src/policies/schemas/policies/merge-deploy-monitor-verify.md +145 -0
- package/src/policies/schemas/policies/parallel-reads.md +24 -0
- package/src/policies/schemas/policies/rtk-wrap.md +26 -0
- package/src/policies/schemas/policies/schema-diff-gate.md +30 -0
- package/src/policies/schemas/policies/session-memory-write.md +24 -0
- package/src/policies/schemas/policies/task-required.md +49 -0
- package/src/policies/schemas/policies/test-gate.md +24 -0
- package/src/policies/schemas/policies/validate-plan-before-build.md +28 -0
- package/src/policies/schemas/policies/worktree-required.md +28 -0
- package/templates/hooks/uap-policy-gate.sh +5 -0
- package/docs/AGENTS.md +0 -423
- package/docs/DOCUMENTATION_AUDIT_REPORT.md +0 -131
- package/docs/GETTING_STARTED.md +0 -288
- package/docs/PROJECT_ANALYSIS_REPORT.md +0 -510
- package/docs/architecture/COMPLETE_ARCHITECTURE.md +0 -748
- package/docs/architecture/EXPERT_STACK.md +0 -137
- package/docs/architecture/MULTI_MODEL.md +0 -224
- package/docs/architecture/PLATFORM_GATING.md +0 -68
- package/docs/architecture/SYSTEM_ANALYSIS.md +0 -334
- package/docs/architecture/UAP_COMPLIANCE.md +0 -217
- package/docs/architecture/UAP_PROTOCOL.md +0 -339
- package/docs/architecture/UAP_STRICT_DROIDS.md +0 -172
- package/docs/archive/BALLS_MODE_SELF_ANALYSIS.md +0 -260
- package/docs/archive/BENCHMARK_GAPS_AND_PLAN.md +0 -146
- package/docs/archive/FAILING_TASKS_SOLUTION_PLAN.md +0 -668
- package/docs/archive/JINJA2-SYSTEM-MESSAGE-FIX.md +0 -209
- package/docs/archive/MODEL_ROUTING_IMPLEMENTATION_SUMMARY.md +0 -281
- package/docs/archive/MODEL_ROUTING_OPTIMIZATION_PLAN.md +0 -320
- package/docs/archive/NPM-PUBLISH-V0.9.1.md +0 -240
- package/docs/archive/OPTIMIZATION_OPTIONS.md +0 -334
- package/docs/archive/PARALLELISM_GAPS_AND_OPTIONS.md +0 -422
- package/docs/archive/POLICY_GATE_IMPLEMENTATION.md +0 -245
- package/docs/archive/SETUP_IMPROVEMENTS.md +0 -213
- package/docs/archive/UAP_GENERIC_OPTIMIZATION_PLAN.md +0 -270
- package/docs/archive/UAP_OPTIMIZATION_PLAN.md +0 -701
- package/docs/archive/UAP_V103_PATTERN_DESIGN.md +0 -315
- package/docs/archive/UAP_V104_COMPLIANCE_DESIGN.md +0 -223
- package/docs/archive/changelog/2026-03-10_uap-100-compliance.md +0 -77
- package/docs/archive/changelog/2026-03-10_uap-full-system-verification.md +0 -109
- package/docs/archive/opencode-integration-guide.md +0 -740
- package/docs/archive/opencode-integration-quickref.md +0 -180
- package/docs/benchmarks/OVERNIGHT_RUNNER.md +0 -341
- package/docs/benchmarks/SPECULATIVE_DECODING_JOURNEY_2026-03.md +0 -221
- package/docs/benchmarks/VALIDATION_PLAN.md +0 -568
- package/docs/blog/SPECULATIVE_DECODING_PRODUCTION_PLAYBOOK.md +0 -139
- package/docs/blog/local-coding-agents.md +0 -266
- package/docs/blog/x-thread.md +0 -254
- package/docs/deployment/DEPLOYMENT.md +0 -895
- package/docs/deployment/DEPLOYMENT_STRATEGIES.md +0 -518
- package/docs/deployment/DEPLOY_BATCHER_ANALYSIS.md +0 -224
- package/docs/deployment/DEPLOY_BATCHING.md +0 -273
- package/docs/deployment/DEPLOY_BUCKETING_ANALYSIS.md +0 -420
- package/docs/deployment/QWEN35_LLAMA_CPP.md +0 -426
- package/docs/deployment/UAP_LLAMA_ANTHROPIC_PROXY_BOOTSTRAP.md +0 -279
- package/docs/getting-started/INTEGRATION.md +0 -628
- package/docs/getting-started/OVERVIEW.md +0 -324
- package/docs/getting-started/SETUP.md +0 -377
- package/docs/integrations/MCP_ROUTER_SETUP.md +0 -445
- package/docs/integrations/RTK_INTEGRATION.md +0 -468
- package/docs/operations/TROUBLESHOOTING.md +0 -660
- package/docs/pr/PR_SPECULATIVE_DOCS_TEMPLATE.md +0 -146
- package/docs/pr/UPSTREAM_PRS.md +0 -424
- package/docs/reference/API_REFERENCE.md +0 -903
- package/docs/reference/EXPERT_DROIDS.md +0 -219
- package/docs/reference/HARNESS-MATRIX.md +0 -318
- package/docs/reference/PATTERN_LIBRARY.md +0 -636
- package/docs/reference/UAP_CLI_REFERENCE.md +0 -620
- package/docs/research/BEHAVIORAL_PATTERNS.md +0 -228
- package/docs/research/DOMAIN_STRATEGIES.md +0 -316
- package/docs/research/MEMORY_SYSTEMS_COMPARISON.md +0 -812
- package/docs/research/PATTERN_ANALYSIS_2026-01-18.md +0 -436
- package/docs/research/PERFORMANCE_ANALYSIS_2026-01-18.md +0 -209
- package/docs/research/PERFORMANCE_TEST_PLAN.md +0 -383
- package/docs/research/TERMINAL_BENCH_LEARNINGS.md +0 -217
|
@@ -1,445 +0,0 @@
|
|
|
1
|
-
# MCP Router Setup Guide
|
|
2
|
-
|
|
3
|
-
The MCP Router provides **98%+ token reduction** by exposing only 2 meta-tools (`discover_tools`, `execute_tool`) instead of loading 150+ individual tool definitions.
|
|
4
|
-
|
|
5
|
-
## Quick Start
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
# Check configured servers
|
|
9
|
-
uap mcp-router list
|
|
10
|
-
|
|
11
|
-
# Show token savings
|
|
12
|
-
uap mcp-router stats
|
|
13
|
-
|
|
14
|
-
# Discover tools
|
|
15
|
-
uap mcp-router discover --query "github issues"
|
|
16
|
-
|
|
17
|
-
# Start as MCP server (for use with Claude/Cursor)
|
|
18
|
-
uap mcp-router start
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
## Configuration
|
|
24
|
-
|
|
25
|
-
### Adding Router to Claude/Cursor
|
|
26
|
-
|
|
27
|
-
Add this to your MCP client config (Claude Desktop, Cursor, etc.):
|
|
28
|
-
|
|
29
|
-
```json
|
|
30
|
-
{
|
|
31
|
-
"mcpServers": {
|
|
32
|
-
"router": {
|
|
33
|
-
"command": "npx",
|
|
34
|
-
"args": ["uap", "mcp-router", "start"]
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
**⚠️ Important**: Do NOT add the router to the config file it reads from!
|
|
41
|
-
|
|
42
|
-
### Backend Server Configuration
|
|
43
|
-
|
|
44
|
-
Create a **separate config file** for the backend MCP servers the router should load.
|
|
45
|
-
|
|
46
|
-
**Option 1: Use existing MCP configs**
|
|
47
|
-
|
|
48
|
-
The router auto-loads from these locations (in order):
|
|
49
|
-
|
|
50
|
-
1. `~/.factory/mcp.json` (Factory.AI)
|
|
51
|
-
2. `~/.claude/settings.json` (Claude CLI)
|
|
52
|
-
3. `~/.config/Code/User/globalStorage/anthropic.claude-code/settings.json` (VS Code)
|
|
53
|
-
4. `~/.config/Cursor/User/globalStorage/cursor.mcp/config.json` (Cursor)
|
|
54
|
-
5. `~/.config/Claude/claude_desktop_config.json` (Claude Desktop)
|
|
55
|
-
6. `./mcp.json` or `./.mcp.json` (local project)
|
|
56
|
-
|
|
57
|
-
**Option 2: Use a dedicated config file**
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
# Create ~/.uap/mcp-backend.json
|
|
61
|
-
mkdir -p ~/.uap
|
|
62
|
-
cat > ~/.uap/mcp-backend.json << 'EOF'
|
|
63
|
-
{
|
|
64
|
-
"mcpServers": {
|
|
65
|
-
"playwright": {
|
|
66
|
-
"command": "npx",
|
|
67
|
-
"args": ["-y", "@playwright/mcp@latest"]
|
|
68
|
-
},
|
|
69
|
-
"chrome-devtools": {
|
|
70
|
-
"command": "npx",
|
|
71
|
-
"args": ["-y", "chrome-devtools-mcp@latest"]
|
|
72
|
-
},
|
|
73
|
-
"filesystem": {
|
|
74
|
-
"command": "npx",
|
|
75
|
-
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/home/user/projects"]
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
EOF
|
|
80
|
-
|
|
81
|
-
# Then run with custom config
|
|
82
|
-
uap mcp-router start --config ~/.uap/mcp-backend.json
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
---
|
|
86
|
-
|
|
87
|
-
## Configuration Features
|
|
88
|
-
|
|
89
|
-
### Automatic Filtering
|
|
90
|
-
|
|
91
|
-
The router automatically excludes:
|
|
92
|
-
|
|
93
|
-
1. **Disabled servers**: Servers with `"disabled": true`
|
|
94
|
-
2. **Self-references**: The router itself (prevents circular reference)
|
|
95
|
-
|
|
96
|
-
#### Example Config with Filtering
|
|
97
|
-
|
|
98
|
-
```json
|
|
99
|
-
{
|
|
100
|
-
"mcpServers": {
|
|
101
|
-
"router": {
|
|
102
|
-
"command": "npx",
|
|
103
|
-
"args": ["uap", "mcp-router", "start"],
|
|
104
|
-
"disabled": false
|
|
105
|
-
},
|
|
106
|
-
"playwright": {
|
|
107
|
-
"command": "npx",
|
|
108
|
-
"args": ["-y", "@playwright/mcp@latest"],
|
|
109
|
-
"disabled": true
|
|
110
|
-
},
|
|
111
|
-
"chrome-devtools": {
|
|
112
|
-
"command": "npx",
|
|
113
|
-
"args": ["-y", "chrome-devtools-mcp@latest"]
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
**Result**: Only `chrome-devtools` is loaded
|
|
120
|
-
|
|
121
|
-
- `router` → Excluded (self-reference)
|
|
122
|
-
- `playwright` → Excluded (disabled)
|
|
123
|
-
- `chrome-devtools` → ✅ Loaded
|
|
124
|
-
|
|
125
|
-
### Environment Variable Expansion
|
|
126
|
-
|
|
127
|
-
The router supports environment variable expansion in configs:
|
|
128
|
-
|
|
129
|
-
```json
|
|
130
|
-
{
|
|
131
|
-
"mcpServers": {
|
|
132
|
-
"custom-server": {
|
|
133
|
-
"command": "node",
|
|
134
|
-
"args": ["${HOME}/servers/my-server.js"],
|
|
135
|
-
"env": {
|
|
136
|
-
"API_KEY": "${API_KEY:-default_key}",
|
|
137
|
-
"PATH": "$env:PATH"
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
Supported patterns:
|
|
145
|
-
|
|
146
|
-
- `${VAR}` - Simple substitution
|
|
147
|
-
- `${VAR:-default}` - With fallback
|
|
148
|
-
- `$env:VAR` - PowerShell-style (cross-platform)
|
|
149
|
-
|
|
150
|
-
---
|
|
151
|
-
|
|
152
|
-
## Usage
|
|
153
|
-
|
|
154
|
-
### As an MCP Server
|
|
155
|
-
|
|
156
|
-
When run with `uap mcp-router start`, the router exposes 2 tools:
|
|
157
|
-
|
|
158
|
-
#### 1. `discover_tools`
|
|
159
|
-
|
|
160
|
-
Find MCP tools matching a query.
|
|
161
|
-
|
|
162
|
-
```typescript
|
|
163
|
-
{
|
|
164
|
-
query: string; // "github issues", "read files", etc.
|
|
165
|
-
limit?: number; // Max results (default: 10)
|
|
166
|
-
server?: string; // Filter to specific server
|
|
167
|
-
}
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
**Example**:
|
|
171
|
-
|
|
172
|
-
```json
|
|
173
|
-
{
|
|
174
|
-
"query": "github issues",
|
|
175
|
-
"limit": 5
|
|
176
|
-
}
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
**Returns**:
|
|
180
|
-
|
|
181
|
-
```json
|
|
182
|
-
{
|
|
183
|
-
"tools": [
|
|
184
|
-
{
|
|
185
|
-
"path": "github.create_issue",
|
|
186
|
-
"name": "create_issue",
|
|
187
|
-
"description": "Create a new GitHub issue",
|
|
188
|
-
"server": "github",
|
|
189
|
-
"score": 0.95
|
|
190
|
-
}
|
|
191
|
-
],
|
|
192
|
-
"hint": "Use execute_tool with path: github.create_issue"
|
|
193
|
-
}
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
#### 2. `execute_tool`
|
|
197
|
-
|
|
198
|
-
Execute a tool by its path.
|
|
199
|
-
|
|
200
|
-
```typescript
|
|
201
|
-
{
|
|
202
|
-
path: string; // "server.tool_name" from discover_tools
|
|
203
|
-
args?: Record<string, any>; // Tool-specific arguments
|
|
204
|
-
}
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
**Example**:
|
|
208
|
-
|
|
209
|
-
```json
|
|
210
|
-
{
|
|
211
|
-
"path": "github.create_issue",
|
|
212
|
-
"args": {
|
|
213
|
-
"title": "Bug: Router not starting",
|
|
214
|
-
"body": "Router fails to start when..."
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
**Returns**:
|
|
220
|
-
|
|
221
|
-
```json
|
|
222
|
-
{
|
|
223
|
-
"success": true,
|
|
224
|
-
"result": {
|
|
225
|
-
/* tool response */
|
|
226
|
-
},
|
|
227
|
-
"toolPath": "github.create_issue",
|
|
228
|
-
"executionTimeMs": 234
|
|
229
|
-
}
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
### CLI Commands
|
|
233
|
-
|
|
234
|
-
#### List Configured Servers
|
|
235
|
-
|
|
236
|
-
```bash
|
|
237
|
-
uap mcp-router list
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
Shows all servers in config (including disabled/filtered ones).
|
|
241
|
-
|
|
242
|
-
#### Show Token Savings
|
|
243
|
-
|
|
244
|
-
```bash
|
|
245
|
-
uap mcp-router stats
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
Example output:
|
|
249
|
-
|
|
250
|
-
```
|
|
251
|
-
MCP Router Statistics
|
|
252
|
-
──────────────────────────────────────────────────
|
|
253
|
-
Servers: 2
|
|
254
|
-
Tools: 48
|
|
255
|
-
|
|
256
|
-
Token Usage Comparison
|
|
257
|
-
──────────────────────────────────────────────────
|
|
258
|
-
Traditional: 24,000 tokens
|
|
259
|
-
With Router: 435 tokens
|
|
260
|
-
Savings: 98.2%
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
#### Discover Tools
|
|
264
|
-
|
|
265
|
-
```bash
|
|
266
|
-
# Search all servers
|
|
267
|
-
uap mcp-router discover --query "github"
|
|
268
|
-
|
|
269
|
-
# Filter to specific server
|
|
270
|
-
uap mcp-router discover --query "create" --server github
|
|
271
|
-
|
|
272
|
-
# Limit results
|
|
273
|
-
uap mcp-router discover --query "file" --limit 3
|
|
274
|
-
|
|
275
|
-
# JSON output
|
|
276
|
-
uap mcp-router discover --query "search" --json
|
|
277
|
-
```
|
|
278
|
-
|
|
279
|
-
---
|
|
280
|
-
|
|
281
|
-
## Troubleshooting
|
|
282
|
-
|
|
283
|
-
### Router Tries to Load Itself
|
|
284
|
-
|
|
285
|
-
**Symptom**: Logs show `[router] router: 2 tools` or startup hangs.
|
|
286
|
-
|
|
287
|
-
**Cause**: The router is in its own config file.
|
|
288
|
-
|
|
289
|
-
**Fix**: Remove the router entry from the config it's reading:
|
|
290
|
-
|
|
291
|
-
```bash
|
|
292
|
-
# Edit the config file
|
|
293
|
-
nano ~/.factory/mcp.json
|
|
294
|
-
|
|
295
|
-
# Remove this section:
|
|
296
|
-
{
|
|
297
|
-
"mcpServers": {
|
|
298
|
-
"router": { ... } // ← DELETE THIS
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
```
|
|
302
|
-
|
|
303
|
-
Or add `"disabled": true`:
|
|
304
|
-
|
|
305
|
-
```json
|
|
306
|
-
{
|
|
307
|
-
"mcpServers": {
|
|
308
|
-
"router": {
|
|
309
|
-
"command": "npx",
|
|
310
|
-
"args": ["uap", "mcp-router", "start"],
|
|
311
|
-
"disabled": true
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
```
|
|
316
|
-
|
|
317
|
-
### No Tools Found
|
|
318
|
-
|
|
319
|
-
**Symptom**: `uap mcp-router stats` shows `0 tools`.
|
|
320
|
-
|
|
321
|
-
**Cause**: No valid backend MCP servers configured.
|
|
322
|
-
|
|
323
|
-
**Fix**: Add backend servers to config:
|
|
324
|
-
|
|
325
|
-
```bash
|
|
326
|
-
# Check what's configured
|
|
327
|
-
uap mcp-router list
|
|
328
|
-
|
|
329
|
-
# If empty, add servers
|
|
330
|
-
cat > ~/.uap/mcp-backend.json << 'EOF'
|
|
331
|
-
{
|
|
332
|
-
"mcpServers": {
|
|
333
|
-
"playwright": {
|
|
334
|
-
"command": "npx",
|
|
335
|
-
"args": ["-y", "@playwright/mcp@latest"]
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
EOF
|
|
340
|
-
|
|
341
|
-
# Test with custom config
|
|
342
|
-
uap mcp-router stats --config ~/.uap/mcp-backend.json
|
|
343
|
-
```
|
|
344
|
-
|
|
345
|
-
### Server Fails to Load
|
|
346
|
-
|
|
347
|
-
**Symptom**: `[router] server-name: failed to load - Error: ...`
|
|
348
|
-
|
|
349
|
-
**Possible causes**:
|
|
350
|
-
|
|
351
|
-
1. Server not installed: `npx` will auto-install on first run
|
|
352
|
-
2. Invalid command/args: Check server documentation
|
|
353
|
-
3. Server requires environment variables: Add to `env` in config
|
|
354
|
-
|
|
355
|
-
**Debug with verbose output**:
|
|
356
|
-
|
|
357
|
-
```bash
|
|
358
|
-
uap mcp-router stats --verbose
|
|
359
|
-
```
|
|
360
|
-
|
|
361
|
-
---
|
|
362
|
-
|
|
363
|
-
## Architecture
|
|
364
|
-
|
|
365
|
-
### Token Reduction Example
|
|
366
|
-
|
|
367
|
-
**Without Router** (48 tools from 2 servers):
|
|
368
|
-
|
|
369
|
-
```
|
|
370
|
-
Tool definitions: 48 × ~500 tokens = 24,000 tokens
|
|
371
|
-
Every request includes all 48 tool schemas
|
|
372
|
-
```
|
|
373
|
-
|
|
374
|
-
**With Router**:
|
|
375
|
-
|
|
376
|
-
```
|
|
377
|
-
Tool definitions: 2 meta-tools = 435 tokens
|
|
378
|
-
discover_tools returns tool paths (not full schemas)
|
|
379
|
-
execute_tool routes to backend servers
|
|
380
|
-
```
|
|
381
|
-
|
|
382
|
-
**Savings**: 98.2% (23,565 tokens saved)
|
|
383
|
-
|
|
384
|
-
### How It Works
|
|
385
|
-
|
|
386
|
-
1. **Startup**: Router loads backend MCP server configs
|
|
387
|
-
2. **Discovery**: On first tool call, router connects to all backend servers and caches tool list
|
|
388
|
-
3. **Search**: `discover_tools` uses fuzzy search to find relevant tools
|
|
389
|
-
4. **Execution**: `execute_tool` spawns the appropriate backend server and forwards the request
|
|
390
|
-
5. **Caching**: Backend servers stay connected in pool for subsequent calls
|
|
391
|
-
|
|
392
|
-
---
|
|
393
|
-
|
|
394
|
-
## Best Practices
|
|
395
|
-
|
|
396
|
-
### ✅ DO
|
|
397
|
-
|
|
398
|
-
- Use separate config for router vs backend servers
|
|
399
|
-
- Enable `disabled: true` for servers you don't want loaded
|
|
400
|
-
- Use `--verbose` to debug startup issues
|
|
401
|
-
- Group related servers (e.g., all GitHub tools in one server)
|
|
402
|
-
|
|
403
|
-
### ❌ DON'T
|
|
404
|
-
|
|
405
|
-
- Add router to the config it reads from (circular reference)
|
|
406
|
-
- Load 150+ backend tools without testing first
|
|
407
|
-
- Forget to check token savings with `uap mcp-router stats`
|
|
408
|
-
- Use router for single-server setups (no benefit)
|
|
409
|
-
|
|
410
|
-
---
|
|
411
|
-
|
|
412
|
-
## Performance
|
|
413
|
-
|
|
414
|
-
Tested with 2 servers (48 tools):
|
|
415
|
-
|
|
416
|
-
| Metric | Value |
|
|
417
|
-
| ---------------------- | ------------------------------------- |
|
|
418
|
-
| Startup time | <1s |
|
|
419
|
-
| First tool discovery | ~2s (loads all backend servers) |
|
|
420
|
-
| Subsequent discoveries | <50ms (cached) |
|
|
421
|
-
| Tool execution | ~500ms (spawns backend server) |
|
|
422
|
-
| Memory overhead | ~50MB (Node.js + backend connections) |
|
|
423
|
-
|
|
424
|
-
---
|
|
425
|
-
|
|
426
|
-
## Related Commands
|
|
427
|
-
|
|
428
|
-
```bash
|
|
429
|
-
# Initialize UAP in a project
|
|
430
|
-
uap init
|
|
431
|
-
|
|
432
|
-
# Memory query with router context
|
|
433
|
-
uap memory query "mcp router setup"
|
|
434
|
-
|
|
435
|
-
# Agent coordination
|
|
436
|
-
uap agent status
|
|
437
|
-
```
|
|
438
|
-
|
|
439
|
-
---
|
|
440
|
-
|
|
441
|
-
## Support
|
|
442
|
-
|
|
443
|
-
- **Issues**: https://github.com/your-org/universal-agent-protocol/issues
|
|
444
|
-
- **Docs**: https://github.com/your-org/universal-agent-protocol/docs
|
|
445
|
-
- **Tests**: `npm test -- mcp-router-filter`
|