@crossdelta/pf-mcp 0.1.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 +389 -0
- package/dist/cli.cjs +2348 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +2379 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.cjs +2489 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +722 -0
- package/dist/index.d.ts +722 -0
- package/dist/index.js +2460 -0
- package/dist/index.js.map +1 -0
- package/package.json +55 -0
package/README.md
ADDED
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
# @crossdelta/pf-mcp
|
|
2
|
+
|
|
3
|
+
Model Context Protocol (MCP) server adapter for Platform SDK.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This package provides a thin adapter layer between the [Model Context Protocol SDK](https://github.com/modelcontextprotocol/typescript-sdk) and the Platform SDK, exposing plugin commands as MCP tools.
|
|
8
|
+
|
|
9
|
+
**Architecture:**
|
|
10
|
+
- Depends on Platform SDK facade (`@crossdelta/platform-sdk/facade`)
|
|
11
|
+
- Pins MCP SDK to exact version for stability
|
|
12
|
+
- Zero business logic - pure adapter pattern
|
|
13
|
+
- Plugin-agnostic: Works with any Platform SDK plugin
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
bun add @crossdelta/pf-mcp
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
### Auto-Discovery (Recommended)
|
|
24
|
+
|
|
25
|
+
The easiest way to start the server - automatically discovers workspace configuration from `package.json`:
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { createMcpServerFromWorkspace } from '@crossdelta/pf-mcp'
|
|
29
|
+
|
|
30
|
+
await createMcpServerFromWorkspace({
|
|
31
|
+
name: 'platform-mcp-server',
|
|
32
|
+
version: '0.1.0',
|
|
33
|
+
plugins: ['@crossdelta/cloudevents']
|
|
34
|
+
})
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
This will:
|
|
38
|
+
- Auto-discover workspace root (walks up from cwd to find package.json with `pf` config)
|
|
39
|
+
- Read contracts package from `pf.contracts` field
|
|
40
|
+
- Discover available services from filesystem
|
|
41
|
+
|
|
42
|
+
### Manual Configuration
|
|
43
|
+
|
|
44
|
+
For more control, you can provide the workspace configuration explicitly:
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { createMcpServer } from '@crossdelta/pf-mcp'
|
|
48
|
+
|
|
49
|
+
await createMcpServer({
|
|
50
|
+
name: 'platform-mcp-server',
|
|
51
|
+
version: '0.1.0',
|
|
52
|
+
workspace: {
|
|
53
|
+
workspaceRoot: process.cwd(),
|
|
54
|
+
contracts: {
|
|
55
|
+
path: 'packages/contracts/src',
|
|
56
|
+
packageName: '@my-org/contracts'
|
|
57
|
+
},
|
|
58
|
+
availableServices: ['orders', 'notifications']
|
|
59
|
+
},
|
|
60
|
+
plugins: ['@crossdelta/cloudevents']
|
|
61
|
+
})
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## MCP SDK Version Strategy
|
|
65
|
+
|
|
66
|
+
### Current Version: `^1.25.1` (v1.x - Latest Stable)
|
|
67
|
+
|
|
68
|
+
This package uses **caret range** for the MCP SDK to receive patch and minor updates automatically.
|
|
69
|
+
|
|
70
|
+
**⚠️ SDK Status**:
|
|
71
|
+
- **v1.x** (`@modelcontextprotocol/sdk`): Current stable, published on npm, uses `Server` class
|
|
72
|
+
- **v2.x** (`@modelcontextprotocol/server`): In development (main branch), not yet published, will use `McpServer` class
|
|
73
|
+
|
|
74
|
+
The `Server` class shows a deprecation warning pointing to `McpServer`, but this is a forward-looking notice for the unreleased v2 API. Our current usage is correct for v1.25.1.
|
|
75
|
+
|
|
76
|
+
#### Why Caret Range?
|
|
77
|
+
|
|
78
|
+
1. **Mature SDK**: MCP SDK is at v1.x with stable APIs
|
|
79
|
+
2. **Automatic bugfixes**: Security patches and fixes without manual intervention
|
|
80
|
+
3. **Semver compliance**: SDK follows semantic versioning
|
|
81
|
+
4. **Facade isolation**: Platform SDK facade provides stability layer
|
|
82
|
+
|
|
83
|
+
#### Version Policy
|
|
84
|
+
|
|
85
|
+
**Updates allowed:**
|
|
86
|
+
- ✅ Patch updates (1.25.1 → 1.25.2) - automatic
|
|
87
|
+
- ✅ Minor updates (1.25.x → 1.26.0) - automatic
|
|
88
|
+
- ❌ Major updates (1.x → 2.0) - manual upgrade required
|
|
89
|
+
|
|
90
|
+
**When to upgrade manually:**
|
|
91
|
+
- New MCP SDK major version with breaking changes
|
|
92
|
+
- New protocol features we want to use
|
|
93
|
+
- Critical security vulnerabilities
|
|
94
|
+
|
|
95
|
+
**Migration to SDK v2.x (future):**
|
|
96
|
+
|
|
97
|
+
When SDK v2 is published to npm (expected Q1 2026):
|
|
98
|
+
1. Install: `bun add @modelcontextprotocol/server` (replaces `@modelcontextprotocol/sdk`)
|
|
99
|
+
2. Update imports: `Server` → `McpServer`, package path: `@modelcontextprotocol/sdk/server` → `@modelcontextprotocol/server`
|
|
100
|
+
3. Review v2 breaking changes in transport/handler APIs
|
|
101
|
+
4. Test with v2 examples: [server.md](https://github.com/modelcontextprotocol/typescript-sdk/blob/main/docs/server.md)
|
|
102
|
+
5. Update this README
|
|
103
|
+
|
|
104
|
+
**How to upgrade:**
|
|
105
|
+
1. Review MCP SDK changelog for breaking changes
|
|
106
|
+
2. Test in dev environment first
|
|
107
|
+
3. Update adapter code if handler APIs changed
|
|
108
|
+
4. Run integration tests
|
|
109
|
+
5. Update version in `package.json`
|
|
110
|
+
6. Document changes in this README
|
|
111
|
+
|
|
112
|
+
### Version History
|
|
113
|
+
|
|
114
|
+
| MCP SDK | Date | Changes | Notes |
|
|
115
|
+
|---------|------|---------|-------|
|
|
116
|
+
| ^1.25.1 | 2025-12-28 | Initial version | v1.x stable release, v2 in development |
|
|
117
|
+
|
|
118
|
+
## Available Tools
|
|
119
|
+
|
|
120
|
+
The MCP server exposes these tools to AI assistants:
|
|
121
|
+
|
|
122
|
+
| Tool | Description |
|
|
123
|
+
|------|-------------|
|
|
124
|
+
| `scan_workspace` | Scan workspace for services, contracts, and configuration |
|
|
125
|
+
| `generate_service` | Generate a plan for a new microservice (dry-run by default) |
|
|
126
|
+
| `plan_review` | Validate a generation plan before applying |
|
|
127
|
+
| `apply_changes` | Apply changes from a generation plan |
|
|
128
|
+
|
|
129
|
+
### MCP Flow (Architecture)
|
|
130
|
+
|
|
131
|
+
**Key Principle:** MCP = Planner (structure), AI = Code Generator (content)
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
1. AI delivers Intent + Inputs → mcp_pf_generate_service(prompt: "...")
|
|
135
|
+
2. pf generates Plan + Preview ← { files: [], changes: [], planHash }
|
|
136
|
+
3. AI generates code for files → AI fills content based on intent + inputs
|
|
137
|
+
4. Optional: plan_review → mcp_pf_plan_review(changes: [...])
|
|
138
|
+
5. User OK Gate → User confirms
|
|
139
|
+
6. Apply with expectedPlanHash → mcp_pf_apply_changes(changes: [...], expectedPlanHash: "...")
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
#### generate_service Response Structure
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
{
|
|
146
|
+
ok: true,
|
|
147
|
+
operation: 'generate_service',
|
|
148
|
+
summary: 'Planned notifications: 10 scaffold files + 3 files for AI to generate',
|
|
149
|
+
|
|
150
|
+
// Scaffold effects (ready to apply - have content)
|
|
151
|
+
changes: [
|
|
152
|
+
{ kind: 'file:write', path: 'services/notifications/package.json', content: '...' },
|
|
153
|
+
{ kind: 'file:write', path: 'services/notifications/src/index.ts', content: '...' },
|
|
154
|
+
// ...
|
|
155
|
+
],
|
|
156
|
+
|
|
157
|
+
// Files for AI to generate (NO content - AI fills based on intent + inputs)
|
|
158
|
+
files: [
|
|
159
|
+
{
|
|
160
|
+
path: 'services/notifications/src/events/order-created.handler.ts',
|
|
161
|
+
intent: 'Handle order.created event',
|
|
162
|
+
inputs: { eventType: 'order.created', contractName: 'OrdersCreatedContract' }
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
path: 'services/notifications/src/adapters/push.adapter.ts',
|
|
166
|
+
intent: 'Push notification adapter using pusher-beams',
|
|
167
|
+
inputs: { provider: 'pusher-beams', envVars: ['PUSHER_BEAMS_INSTANCE_ID', 'PUSHER_BEAMS_SECRET_KEY'] }
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
|
|
171
|
+
// Dependencies to add
|
|
172
|
+
dependencies: [
|
|
173
|
+
{ name: '@pusher/push-notifications-server', version: '^1.0.0' }
|
|
174
|
+
],
|
|
175
|
+
|
|
176
|
+
// Environment variables needed
|
|
177
|
+
envVars: [
|
|
178
|
+
{ key: 'PUSHER_BEAMS_INSTANCE_ID', description: 'Pusher Beams instance ID', required: true }
|
|
179
|
+
],
|
|
180
|
+
|
|
181
|
+
// Integrity hash
|
|
182
|
+
planHash: 'abc123...',
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
#### AI Workflow
|
|
187
|
+
|
|
188
|
+
1. **Call generate_service** with prompt
|
|
189
|
+
2. **Read files array** (path + intent + inputs)
|
|
190
|
+
3. **Generate code** for each file based on intent + inputs
|
|
191
|
+
4. **Merge into changes** with AI-generated content
|
|
192
|
+
5. **Call apply_changes** with merged changes + expectedPlanHash
|
|
193
|
+
|
|
194
|
+
### Effect Types
|
|
195
|
+
|
|
196
|
+
| Effect Kind | Description |
|
|
197
|
+
|-------------|-------------|
|
|
198
|
+
| `file:write` | Write file to filesystem |
|
|
199
|
+
| `env:add` | Add environment variable to .env.local |
|
|
200
|
+
| `infra:add` | Create infrastructure config |
|
|
201
|
+
| `deps:add` | Add dependency to package.json |
|
|
202
|
+
|
|
203
|
+
### Tool Examples
|
|
204
|
+
|
|
205
|
+
#### scan_workspace
|
|
206
|
+
```json
|
|
207
|
+
{
|
|
208
|
+
"name": "scan_workspace",
|
|
209
|
+
"arguments": {}
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
#### generate_service (dry-run)
|
|
214
|
+
```json
|
|
215
|
+
{
|
|
216
|
+
"name": "generate_service",
|
|
217
|
+
"arguments": {
|
|
218
|
+
"template": "hono-bun",
|
|
219
|
+
"name": "order-processor",
|
|
220
|
+
"events": ["order.created", "order.updated"]
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
#### generate_service (apply)
|
|
226
|
+
```json
|
|
227
|
+
{
|
|
228
|
+
"name": "generate_service",
|
|
229
|
+
"arguments": {
|
|
230
|
+
"template": "hono-bun",
|
|
231
|
+
"name": "order-processor",
|
|
232
|
+
"events": ["order.created"],
|
|
233
|
+
"dryRun": false
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## Testing
|
|
239
|
+
|
|
240
|
+
### Manual Testing (CLI)
|
|
241
|
+
|
|
242
|
+
Test the MCP server directly via stdin/stdout:
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
# Build the package first
|
|
246
|
+
cd packages/pf-mcp && bun run build
|
|
247
|
+
|
|
248
|
+
# From workspace root - list available tools
|
|
249
|
+
cd /path/to/workspace
|
|
250
|
+
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | bun run packages/pf-mcp/bin/server.ts
|
|
251
|
+
|
|
252
|
+
# Scan workspace
|
|
253
|
+
echo '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"scan_workspace","arguments":{}}}' | bun run packages/pf-mcp/bin/server.ts
|
|
254
|
+
|
|
255
|
+
# Generate service (dry-run)
|
|
256
|
+
echo '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"generate_service","arguments":{"template":"hono-bun","name":"test-service","events":["order.created"]}}}' | bun run packages/pf-mcp/bin/server.ts
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### VS Code Integration (Copilot Agent Mode)
|
|
260
|
+
|
|
261
|
+
Add to your VS Code `settings.json`:
|
|
262
|
+
|
|
263
|
+
```json
|
|
264
|
+
{
|
|
265
|
+
"github.copilot.chat.mcpServers": {
|
|
266
|
+
"pf": {
|
|
267
|
+
"command": "bun",
|
|
268
|
+
"args": ["run", "${workspaceFolder}/packages/pf-mcp/bin/server.ts"],
|
|
269
|
+
"env": {}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
Or for the built version (npm package):
|
|
276
|
+
|
|
277
|
+
```json
|
|
278
|
+
{
|
|
279
|
+
"github.copilot.chat.mcpServers": {
|
|
280
|
+
"pf": {
|
|
281
|
+
"command": "node",
|
|
282
|
+
"args": ["${workspaceFolder}/node_modules/@crossdelta/pf-mcp/dist/cli.js", "--stdio"],
|
|
283
|
+
"env": {}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
After configuration, restart VS Code. The tools will appear with `mcp_pf_` prefix in Copilot Agent Mode.
|
|
290
|
+
|
|
291
|
+
### Unit Tests
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
cd packages/pf-mcp
|
|
295
|
+
bun test
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
## Development
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
# Build
|
|
302
|
+
bun run build
|
|
303
|
+
|
|
304
|
+
# Test
|
|
305
|
+
bun test
|
|
306
|
+
|
|
307
|
+
# Watch mode
|
|
308
|
+
bun run dev
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
## Architecture
|
|
312
|
+
|
|
313
|
+
```
|
|
314
|
+
┌─────────────────┐
|
|
315
|
+
│ MCP Client │ (Claude Desktop, Zed, etc.)
|
|
316
|
+
└────────┬────────┘
|
|
317
|
+
│ stdio
|
|
318
|
+
┌────────▼────────┐
|
|
319
|
+
│ pf-mcp Server │ (this package - thin adapter)
|
|
320
|
+
└────────┬────────┘
|
|
321
|
+
│ facade API
|
|
322
|
+
┌────────▼────────┐
|
|
323
|
+
│ Platform SDK │ (plugin system, execution engine)
|
|
324
|
+
│ Facade │
|
|
325
|
+
└────────┬────────┘
|
|
326
|
+
│
|
|
327
|
+
┌────────▼────────┐
|
|
328
|
+
│ Plugins │ (@crossdelta/cloudevents, etc.)
|
|
329
|
+
└─────────────────┘
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### Design Principles
|
|
333
|
+
|
|
334
|
+
1. **Thin adapter**: No business logic, pure protocol translation
|
|
335
|
+
2. **Facade dependency**: Only imports from `@crossdelta/platform-sdk/facade`
|
|
336
|
+
3. **Plugin agnostic**: Works with any plugin conforming to `PfPlugin` interface
|
|
337
|
+
4. **Exact SDK pin**: MCP SDK version explicitly controlled for stability
|
|
338
|
+
|
|
339
|
+
### Facade API Surface
|
|
340
|
+
|
|
341
|
+
This package depends on these stable facade exports:
|
|
342
|
+
|
|
343
|
+
```typescript
|
|
344
|
+
import {
|
|
345
|
+
loadPlugins, // Load plugins from module names
|
|
346
|
+
createContext, // Create plugin context
|
|
347
|
+
collectToolSpecs, // Transform commands → tool specs
|
|
348
|
+
applyEffects, // Apply command effects
|
|
349
|
+
// Types
|
|
350
|
+
type PfPluginContext,
|
|
351
|
+
type PfWorkspaceContext,
|
|
352
|
+
type LoadedPlugin,
|
|
353
|
+
type ToolSpec,
|
|
354
|
+
} from '@crossdelta/platform-sdk/facade'
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
The facade provides version stability - Platform SDK can refactor internals without breaking this adapter.
|
|
358
|
+
|
|
359
|
+
## Roadmap
|
|
360
|
+
|
|
361
|
+
### Phase 1: Core Tools (Current)
|
|
362
|
+
- [x] Server skeleton with stdio transport
|
|
363
|
+
- [x] `tools/list` handler
|
|
364
|
+
- [x] `tools/call` handler with command execution
|
|
365
|
+
- [x] Effect application via facade
|
|
366
|
+
- [ ] Full integration tests with mock plugins
|
|
367
|
+
- [ ] Error handling and validation
|
|
368
|
+
- [ ] Logging and debugging support
|
|
369
|
+
|
|
370
|
+
### Phase 2: Enhanced Capabilities
|
|
371
|
+
- [ ] `resources/list` - workspace contracts as resources
|
|
372
|
+
- [ ] `resources/read` - contract content retrieval
|
|
373
|
+
- [ ] `prompts/list` - template-based prompts
|
|
374
|
+
- [ ] `prompts/get` - prompt resolution
|
|
375
|
+
- [ ] Plan/apply separation for safety
|
|
376
|
+
|
|
377
|
+
### Phase 3: Advanced Features
|
|
378
|
+
- [ ] Progress reporting via notifications
|
|
379
|
+
- [ ] Streaming responses for long operations
|
|
380
|
+
- [ ] Workspace change notifications
|
|
381
|
+
- [ ] Multi-workspace support
|
|
382
|
+
|
|
383
|
+
## Contributing
|
|
384
|
+
|
|
385
|
+
This package is part of the Platform SDK monorepo. See the main repository for contribution guidelines.
|
|
386
|
+
|
|
387
|
+
## License
|
|
388
|
+
|
|
389
|
+
MIT
|