@chapterdev/mcp-dev-studio 0.0.0-stage → 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.
@@ -0,0 +1,17 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>MCP Dev Studio</title>
7
+ <link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><rect width='32' height='32' rx='8' fill='%238b7cf6'/><path d='M9 22l7-12 7 12' stroke='white' stroke-width='3' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>" />
8
+ <script>
9
+ try { const t = localStorage.getItem('studio-theme'); if (t) document.documentElement.dataset.theme = t } catch {}
10
+ </script>
11
+ <script type="module" crossorigin src="/assets/index-DWc84XNR.js"></script>
12
+ <link rel="stylesheet" crossorigin href="/assets/index-89JVDkhA.css">
13
+ </head>
14
+ <body>
15
+ <div id="root"></div>
16
+ </body>
17
+ </html>
@@ -0,0 +1,195 @@
1
+ // The project the studio is open on, and the server it's connected to.
2
+ //
3
+ // The server can change while the studio runs (the connect screen), so the
4
+ // connection, store and skills live here and the HTTP API reads them on every
5
+ // request. It also owns a local HTTP server's dev process when the studio
6
+ // started it, and stops it on exit.
7
+ import { EventEmitter } from 'node:events';
8
+ import { spawn } from 'node:child_process';
9
+ import { createHash } from 'node:crypto';
10
+ import { existsSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
11
+ import { homedir } from 'node:os';
12
+ import { basename, dirname, join } from 'node:path';
13
+ import { fileURLToPath } from 'node:url';
14
+ import { McpConnection } from './mcp/connection.js';
15
+ import { Store } from './store.js';
16
+ import { SkillStore } from './skills/skills.js';
17
+ import { seedDemo } from './demo/seed.js';
18
+ import { probe } from './discover.js';
19
+ const here = dirname(fileURLToPath(import.meta.url));
20
+ export const DEMO_ENTRY = join(here, 'demo', 'stdio.js');
21
+ const UNSET = { kind: 'stdio', command: '' };
22
+ const SHARED_README = `# MCP Dev Studio tests
23
+
24
+ Tests for this repo's MCP server: prompts, and what a real agent (Claude Code, Codex) should do with them.
25
+ Run them with \`npx @chapterdev/mcp-dev-studio\` (Tests tab) or \`npx @chapterdev/mcp-dev-studio eval\`.
26
+ Each person's results and history stay on their own machine; only the tests are shared.
27
+ `;
28
+ export class Workspace extends EventEmitter {
29
+ project;
30
+ opts;
31
+ conn;
32
+ store;
33
+ skills;
34
+ demo = false;
35
+ dev;
36
+ constructor(project, opts = {}) {
37
+ super();
38
+ this.project = project;
39
+ this.opts = opts;
40
+ this.store = new Store(this.storeRoot(false));
41
+ this.useSharedTests();
42
+ this.skills = new SkillStore(this.skillsDir(false));
43
+ this.conn = new McpConnection(UNSET, { unset: true });
44
+ }
45
+ /**
46
+ * Hidden by default: the studio's data lives in ~/.mcp-dev-studio/projects/<repo>-<hash>,
47
+ * so nothing shows up in the repo. A repo that already has a full .mcp-dev-studio/
48
+ * (settings, tests…) from an earlier version keeps using it.
49
+ */
50
+ storeRoot(demo) {
51
+ if (this.opts.store)
52
+ return this.opts.store;
53
+ const local = join(this.project, '.mcp-dev-studio');
54
+ const legacy = ['settings.json', 'journeys', 'demo'].some((f) => existsSync(join(local, f)));
55
+ const base = legacy ? local : join(homedir(), '.mcp-dev-studio', 'projects', `${basename(this.project).replace(/[^\w.-]+/g, '-')}-${createHash('sha1').update(this.project).digest('hex').slice(0, 8)}`);
56
+ return demo ? join(base, 'demo') : base;
57
+ }
58
+ /** Tests shared with the team: <repo>/.mcp-dev-studio/tests, committed with the code. */
59
+ get sharedTestsDir() {
60
+ return join(this.project, '.mcp-dev-studio', 'tests');
61
+ }
62
+ useSharedTests() {
63
+ if (!this.demo && existsSync(this.sharedTestsDir))
64
+ this.store.testsDir = this.sharedTestsDir;
65
+ }
66
+ /** Share the tests with the team (move them into the repo), or make them private again. */
67
+ shareTests(on) {
68
+ if (on) {
69
+ this.store.moveTests(this.sharedTestsDir);
70
+ const readme = join(this.project, '.mcp-dev-studio', 'README.md');
71
+ if (!existsSync(readme))
72
+ writeFileSync(readme, SHARED_README);
73
+ }
74
+ else {
75
+ this.store.moveTests(undefined);
76
+ // Leave the repo as it was: drop the folder if nothing else is in it.
77
+ for (const dir of [this.sharedTestsDir, join(this.project, '.mcp-dev-studio')]) {
78
+ try {
79
+ const left = readdirSync(dir).filter((f) => f !== 'README.md');
80
+ if (!left.length)
81
+ rmSync(dir, { recursive: true, force: true });
82
+ }
83
+ catch {
84
+ /* gone already */
85
+ }
86
+ }
87
+ }
88
+ this.emit('tests-moved');
89
+ }
90
+ /**
91
+ * --skills, else where the repo already keeps its skills: skills/, .claude/skills/
92
+ * (Claude Code) or .agents/skills/ (Codex), first one holding a SKILL.md.
93
+ * Otherwise a private folder in the store.
94
+ */
95
+ skillsDir(demo) {
96
+ if (this.opts.skills)
97
+ return this.opts.skills;
98
+ if (!demo) {
99
+ for (const rel of ['skills', '.claude/skills', '.agents/skills']) {
100
+ const dir = join(this.project, rel);
101
+ try {
102
+ if (readdirSync(dir).some((d) => d !== 'mcp-dev-studio' && existsSync(join(dir, d, 'SKILL.md'))))
103
+ return dir;
104
+ }
105
+ catch {
106
+ /* none here */
107
+ }
108
+ }
109
+ }
110
+ return join(this.storeRoot(demo), 'skills');
111
+ }
112
+ get unset() {
113
+ return !!this.conn.state.unset;
114
+ }
115
+ /** Point the studio at a server. Resolves once connected; throws with a readable reason if it can't. */
116
+ async open(choice, onLog) {
117
+ await this.stopServer();
118
+ const demo = !!choice.demo;
119
+ const target = demo ? { kind: 'stdio', command: `"${process.execPath}" "${DEMO_ENTRY}"` } : choice.target;
120
+ if (demo !== this.demo || this.unset) {
121
+ this.store = new Store(this.storeRoot(demo));
122
+ // Seed before SkillStore creates the folder: seeding skips a folder that exists.
123
+ if (demo)
124
+ seedDemo(this.store, this.skillsDir(demo));
125
+ this.skills = new SkillStore(this.skillsDir(demo));
126
+ }
127
+ this.demo = demo;
128
+ this.useSharedTests();
129
+ const conn = new McpConnection(target, {
130
+ demo,
131
+ name: choice.name,
132
+ watch: this.opts.watch ?? (demo ? [dirname(DEMO_ENTRY)] : undefined),
133
+ onTraffic: (e) => this.store.appendTraffic([e]),
134
+ });
135
+ this.conn = conn;
136
+ this.emit('switch');
137
+ if (target.kind === 'http' && choice.start && !(await probe(target.url, target.headers)).running) {
138
+ await this.startServer(target.url, choice.start, (l) => (conn.note(l), onLog?.(l)));
139
+ }
140
+ await conn.connect();
141
+ if (choice.save && !demo)
142
+ this.store.saveServer({ name: choice.name, target, start: choice.start });
143
+ }
144
+ /** Run a local HTTP server's dev command and wait until its URL answers. */
145
+ async startServer(url, start, log) {
146
+ log(`$ ${start.command}`);
147
+ const child = spawn(start.command, { cwd: start.cwd, shell: true, detached: process.platform !== 'win32', stdio: ['ignore', 'pipe', 'pipe'], env: { ...process.env, FORCE_COLOR: '0' } });
148
+ this.dev = child;
149
+ // Don't leave the dev server behind if the studio dies without cleaning up.
150
+ process.once('exit', () => {
151
+ try {
152
+ if (child.exitCode === null && child.pid)
153
+ process.kill(process.platform === 'win32' ? child.pid : -child.pid, 'SIGTERM');
154
+ }
155
+ catch {
156
+ /* gone */
157
+ }
158
+ });
159
+ const tail = [];
160
+ const onData = (d) => d.toString().split('\n').filter(Boolean).forEach((l) => (tail.push(l), tail.length > 30 && tail.shift(), log(l)));
161
+ child.stdout?.on('data', onData);
162
+ child.stderr?.on('data', onData);
163
+ let exited;
164
+ child.on('exit', (code) => (exited = code));
165
+ const until = Date.now() + 120_000;
166
+ while (Date.now() < until) {
167
+ if (exited !== undefined)
168
+ throw new Error(`\`${start.command}\` exited (code ${exited}) before ${url} came up:\n${tail.slice(-8).join('\n')}`);
169
+ if ((await probe(url, undefined, 1000)).running)
170
+ return;
171
+ await new Promise((r) => setTimeout(r, 750));
172
+ }
173
+ throw new Error(`${url} didn't come up within 2 minutes of \`${start.command}\``);
174
+ }
175
+ async stopServer() {
176
+ await this.conn.close().catch(() => { });
177
+ const child = this.dev;
178
+ this.dev = undefined;
179
+ if (!child || child.exitCode !== null)
180
+ return;
181
+ try {
182
+ if (child.pid && process.platform !== 'win32')
183
+ process.kill(-child.pid, 'SIGTERM');
184
+ else
185
+ child.kill('SIGTERM');
186
+ }
187
+ catch {
188
+ /* already gone */
189
+ }
190
+ }
191
+ async close() {
192
+ await this.stopServer();
193
+ }
194
+ }
195
+ //# sourceMappingURL=workspace.js.map
package/package.json CHANGED
@@ -1,6 +1,81 @@
1
1
  {
2
2
  "name": "@chapterdev/mcp-dev-studio",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Test your MCP server and skills in real Claude Code and Codex, watch every run live, and let Claude iterate until they pass.",
5
+ "license": "MIT",
6
+ "author": "Chapter Dev Pty Ltd",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/chapter-dev-pty-ltd/mcp-dev-studio.git"
10
+ },
11
+ "homepage": "https://github.com/chapter-dev-pty-ltd/mcp-dev-studio#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/chapter-dev-pty-ltd/mcp-dev-studio/issues"
14
+ },
15
+ "keywords": [
16
+ "mcp",
17
+ "model-context-protocol",
18
+ "agent-skills",
19
+ "claude-code",
20
+ "codex",
21
+ "evals",
22
+ "testing"
23
+ ],
24
+ "type": "module",
25
+ "bin": {
26
+ "mcp-dev-studio": "./bin/mcp-dev-studio.js"
27
+ },
28
+ "files": [
29
+ "bin",
30
+ "dist",
31
+ "!dist/test",
32
+ "!dist/**/*.map"
33
+ ],
34
+ "scripts": {
35
+ "build": "tsc -p tsconfig.json && vite build",
36
+ "build:server": "tsc -p tsconfig.json",
37
+ "dev:ui": "vite",
38
+ "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p ui/tsconfig.json --noEmit",
39
+ "demo": "node bin/mcp-dev-studio.js demo",
40
+ "test": "tsc -p tsconfig.json && node --test dist/test/*.test.js",
41
+ "prepublishOnly": "npm run build && npm test"
42
+ },
43
+ "engines": {
44
+ "node": ">=20"
45
+ },
46
+ "dependencies": {
47
+ "@anthropic-ai/sdk": "^1.14.0",
48
+ "@modelcontextprotocol/sdk": "^1.32.2",
49
+ "express": "^5.3.0",
50
+ "openai": "^7.64.0",
51
+ "yaml": "^2.9.1",
52
+ "zod": "^4.3.5"
53
+ },
54
+ "devDependencies": {
55
+ "@codemirror/autocomplete": "^6.20.4",
56
+ "@codemirror/commands": "^6.11.2",
57
+ "@codemirror/lang-markdown": "^6.5.2",
58
+ "@codemirror/language": "^6.13.1",
59
+ "@codemirror/lint": "^6.9.8",
60
+ "@codemirror/state": "^6.7.6",
61
+ "@codemirror/view": "^6.44.0",
62
+ "@lezer/highlight": "^1.2.5",
63
+ "@tailwindcss/vite": "^4.3.5",
64
+ "@types/express": "^5.0.6",
65
+ "@types/node": "^26.6.11",
66
+ "@types/react": "^19.3.3",
67
+ "@types/react-dom": "^19.3.0",
68
+ "@vitejs/plugin-react": "^6.3.0",
69
+ "react": "^19.3.1",
70
+ "react-dom": "^19.3.1",
71
+ "tailwindcss": "^4.3.5",
72
+ "typescript": "^7.0.2",
73
+ "vite": "^8.3.8"
74
+ },
75
+ "exports": {
76
+ "./package.json": "./package.json"
77
+ },
78
+ "publishConfig": {
79
+ "access": "public"
80
+ }
81
+ }