@bicon/mcp-composer 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.
Files changed (3) hide show
  1. package/README.md +136 -0
  2. package/dist/index.mjs +6794 -0
  3. package/package.json +45 -0
package/README.md ADDED
@@ -0,0 +1,136 @@
1
+ # BICon Initiative Composer (MCP server)
2
+
3
+ An [MCP](https://modelcontextprotocol.io) server that helps an AI client — e.g.
4
+ Claude Desktop — set up a portfolio initiative conversationally. Creating an
5
+ initiative by hand means filling ~15 metadata fields **and rating 30
6
+ sub-dimensions across four scoring dimensions** (plus optional economics and a
7
+ large EU-AI-Act block); this server lets an assistant run that interview and
8
+ produce a complete, valid initiative.
9
+
10
+ ## Draft-first by design — no auth, no API calls
11
+
12
+ The server holds **no credentials and never talks to the BICon API**. Its tools
13
+ assemble and validate an initiative and hand back an **import file**; you load
14
+ that file through the app's existing, authenticated import UI. The
15
+ "Add as new → Confirm" step in the app is the human-in-the-loop — nothing
16
+ reaches your organisation until you confirm it in the browser.
17
+
18
+ Why: the API only accepts short-lived browser session tokens (there is no API
19
+ key), and a draft-first flow adds zero new attack surface. Live create/update
20
+ via API keys is a separate, security-reviewed phase.
21
+
22
+ ## Tools & resource
23
+
24
+ | Name | What it does |
25
+ |---|---|
26
+ | resource `initiative://schema` / tool `get_initiative_schema` | The field catalog: required fields, enum values, the four dimensions with their named sub-dimensions (EN/DE labels + help text), confidence scale, optional sections, and the handoff steps. **Read this first.** |
27
+ | `assemble_initiative` | Compact spec (metadata + named sub-ratings 0–100 + confidence per dimension) → fully-formed initiative validated against the API contract (`CreateInitiativeBody` from `@workspace/api-zod`). Mints id/timestamps, **derives** the four dimension scores (mean of subs, like the app), returns `{ok, initiative, derivedScores, warnings, errors}` with precise per-field errors. |
28
+ | `export_initiative_file` | Wraps an assembled initiative in the app's single-initiative JSON envelope; returns `{filename, json, importInstructions, derivedScores}`. |
29
+
30
+ The score derivation is a test-pinned copy of the app's `scoring.ts`
31
+ (golden test against the "Advisor Copilot" demo seed → 77 / 61 / 73 / 90),
32
+ and a catalog-drift test fails the build if the OpenAPI contract's enums or
33
+ sub-dimension keys change without a catalog update.
34
+
35
+ ## Install for users (no clone, no build)
36
+
37
+ The package is published to npm as `@bicon/mcp-composer` — a single
38
+ self-contained bundle whose only runtime dependency is the MCP SDK. Any user
39
+ with Node ≥ 20 adds this to Claude Desktop's `claude_desktop_config.json`
40
+ (Settings → Developer → Edit Config) and restarts:
41
+
42
+ ```json
43
+ {
44
+ "mcpServers": {
45
+ "bicon-composer": {
46
+ "command": "npx",
47
+ "args": ["-y", "@bicon/mcp-composer"]
48
+ }
49
+ }
50
+ }
51
+ ```
52
+
53
+ That's the whole install. `npx -y` fetches (and caches) the published version;
54
+ no repository, no terminal work.
55
+
56
+ ## Build & run from source (contributors)
57
+
58
+ ```bash
59
+ pnpm --filter @bicon/mcp-composer run build # → dist/index.mjs (single ESM bundle)
60
+ pnpm --filter @bicon/mcp-composer run test # vitest
61
+ node lib/integrations/mcp/dist/index.mjs # stdio server (used by the client, not by hand)
62
+ ```
63
+
64
+ Point Claude Desktop at the local build with the **absolute path**:
65
+
66
+ ```json
67
+ {
68
+ "mcpServers": {
69
+ "bicon-composer": {
70
+ "command": "node",
71
+ "args": ["/ABSOLUTE/PATH/TO/lib/integrations/mcp/dist/index.mjs"]
72
+ }
73
+ }
74
+ }
75
+ ```
76
+
77
+ On Windows with the repo in WSL, run the server **inside WSL** so it sees the
78
+ Linux `node`:
79
+
80
+ ```json
81
+ {
82
+ "mcpServers": {
83
+ "bicon-composer": {
84
+ "command": "wsl.exe",
85
+ "args": ["-d", "Ubuntu", "--", "/home/<user>/.nvm/versions/node/<version>/bin/node",
86
+ "/home/<user>/projects/ai-portfolio-steering/lib/integrations/mcp/dist/index.mjs"]
87
+ }
88
+ }
89
+ }
90
+ ```
91
+
92
+ Restart Claude Desktop; the tools appear under the tools menu.
93
+
94
+ ## Using it (the interview → import flow)
95
+
96
+ 1. Ask Claude: *"Help me set up a new initiative in BICon."* It reads
97
+ `initiative://schema` and interviews you — metadata first, then the 30
98
+ sub-dimensions with the app's own help text, then a confidence per dimension.
99
+ 2. Claude calls `assemble_initiative` and shows you the **derived scores** as a
100
+ sanity check (fix and re-run if anything looks off).
101
+ 3. Claude calls `export_initiative_file` → save the returned JSON under the
102
+ suggested filename (`initiative-<name>-<date>.json`).
103
+ 4. In the app (signed in to the target organisation): **Import/Export →
104
+ Single initiative** card → drop the file → the preview should show
105
+ **0 warnings** → **Add as new** → **Confirm**.
106
+ 5. The initiative appears in the Inventory with exactly the scores Claude
107
+ reported.
108
+
109
+ `sourceMode` (default `ai`) must match the target portfolio's mode, otherwise the
110
+ importer strips the AI-Act fields.
111
+
112
+ ## Publishing (maintainers)
113
+
114
+ The bundle inlines `zod` and `@workspace/api-zod` (a workspace-only
115
+ devDependency the registry cannot resolve), so what ships is
116
+ `dist/index.mjs` + this README with `@modelcontextprotocol/sdk` as the sole
117
+ runtime dependency — `publish-shape.test.ts` guards exactly that. Publish under
118
+ the BICon npm account (business identity, 2FA on):
119
+
120
+ ```bash
121
+ cd lib/integrations/mcp
122
+ pnpm run pack:check # builds, then `npm pack --dry-run` — inspect the file list
123
+ npm login # once, as the BICon npm account
124
+ npm version patch|minor # bumps package.json version + creates a git tag
125
+ npm publish # prepack runs the build; publishConfig.access is public
126
+ ```
127
+
128
+ Then verify from a clean machine: `npx -y @bicon/mcp-composer` should start
129
+ (it waits for stdio input; Ctrl-C to exit).
130
+
131
+ ## Not in scope (Phase 2)
132
+
133
+ No authentication, no live `POST /initiatives`, no read/list/update tools, no
134
+ hosted/HTTP transport. Those require an API-key auth path in the API server that
135
+ doesn't exist yet — deliberately deferred to a separate, security-reviewed
136
+ phase after the production Clerk split.