Skip to content

feat: ship .mcp.json with scaffolded projects (#55)#56

Merged
hifi-phil merged 6 commits intodevfrom
feat/55-template-mcp-json
Apr 21, 2026
Merged

feat: ship .mcp.json with scaffolded projects (#55)#56
hifi-phil merged 6 commits intodevfrom
feat/55-template-mcp-json

Conversation

@hifi-phil
Copy link
Copy Markdown
Contributor

Summary

  • Add template/.mcp.json so every scaffolded project is immediately testable in Claude Code after init + discover + npm run build — no manual claude mcp add required
  • Update template/README.md with a "Testing with Claude Code" section describing the full setup flow
  • Update template/CLAUDE.md to reference .mcp.json in the testing section
  • Update root CLAUDE.md to note that scaffolded projects ship with .mcp.json
  • Extend packages/create-mcp-server/src/scaffold.ts next-steps output to include discover, build, and claude . steps pointing users at Claude Code
  • Add a scaffold unit test asserting .mcp.json is emitted into every new project
  • Update the template-structure snapshot to include .mcp.json in the file listing

Design decision: Option 2 — node --env-file=.env ./dist/index.js

.mcp.json uses the Node.js 22 --env-file flag to load credentials at startup:

{
  "mcpServers": {
    "umbraco": {
      "command": "node",
      "args": ["--env-file=.env", "./dist/index.js"]
    }
  }
}

Rationale: .env is already gitignored by the template and populated by init. Inlining credentials in .mcp.json (option 1 / example file approach) would either require an extra init step to write the real file or leave secrets in git. With --env-file=.env the committed file is always safe, init writes exactly one file (.env, which it was already doing), and there is no .mcp.json.example / .mcp.json duplication to confuse users. Node.js 22 is the minimum runtime required by the template, so --env-file is always available.

NODE_TLS_REJECT_UNAUTHORIZED=0 is already in .env.example (and therefore in the .env that init produces), so local HTTPS with self-signed certs works out of the box.

Test commands run

Command Result
npm install ✅ pass
npm run build ✅ pass
npm run test ✅ 456 tests passed (479 total incl. stdio suite)
npm test -w packages/hosted-mcp ✅ 191 tests passed
npm run build -w packages/create-mcp-server ✅ pass (copies template to dist/)
npm test -w packages/create-mcp-server ✅ 122 tests passed (up from 121; new .mcp.json test added)
npm run build -w template ✅ pass
npm run test:template ✅ 24 tests passed

Tests skipped and why

Command Reason skipped
npm run test:cli Requires a running Umbraco instance (dotnet run) — not available in this env
npm run test:integration / test:integration:chained Requires Wrangler + running worker — not available
npm run test:e2e / test:e2e:chained Requires Playwright + running Umbraco instance — not available
npm run test:cli:evals Requires ANTHROPIC_API_KEY or Claude Code subscription
TEST_SQL_CONNECTION_STRING=... npm run test:e2e -w packages/create-mcp-server Requires SQL Server + .NET 10 — not available

Conflict note

Issue #52 (unify init around {url, username, password}) is in flight in parallel. That PR will change how init populates .env. The .mcp.json added here is unaffected by that change — both options write the same credentials to .env. No resolution needed here; whichever PR lands second will not conflict on .mcp.json itself.

Closes #55

claude and others added 6 commits April 21, 2026 12:35
Add template/.mcp.json using `node --env-file=.env ./dist/index.js` so
every scaffolded project is immediately testable in Claude Code after
init + discover + npm run build, with no manual `claude mcp add` required.

- template/.mcp.json: registers the MCP server via stdio, reads credentials
  from .env at startup (Node 22 --env-file flag; no secrets in git)
- template/README.md: add "Testing with Claude Code" section
- template/CLAUDE.md: reference .mcp.json in the testing section
- CLAUDE.md (root): note that scaffolded projects ship with .mcp.json
- packages/create-mcp-server/src/scaffold.ts: extend next-steps output
  to include discover, build, and `claude .` steps
- packages/create-mcp-server/src/__tests__/scaffold.test.ts: add test
  asserting .mcp.json is emitted into the scaffolded project
- template-structure snapshot updated to include .mcp.json in file listing

https://claude.ai/code/session_01Pmjb71MfDGFeDmqbx9nj1K
The previous "claude ." suggestion appeared before /build-tools, so
users were told to exercise tools that hadn't been generated yet. Drop
the premature `npm run build` + `claude .` lines and replace them with
a note pointing users through the plugin's tool-build phase first.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drop the trailing prose lines about the Claude Code plugin and
`.mcp.json` from the post-scaffold console output. Terminal output
should stay terse — the plugin/testing workflow is covered in the
docs, not repeated here.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
After /build-tools and /build-tools-tests, the user still needs to
build the server and know that .mcp.json makes it immediately callable
in Claude Code. Add steps 5 and 6 to complete the flow.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Step 6 ("your tools are now callable via .mcp.json") added nothing — by
the time /build-tools-tests has run, the user is already in Claude Code
and the shipped .mcp.json works without being announced.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
scaffold.ts should stay as-is. The init command already prints a full
"Next steps" list pointing users at discover, so adding discover to
the post-scaffold output duplicates guidance the user sees at the
right moment anyway.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hifi-phil hifi-phil merged commit 0f63a08 into dev Apr 21, 2026
7 checks passed
@hifi-phil hifi-phil mentioned this pull request Apr 22, 2026
4 tasks
hifi-phil added a commit that referenced this pull request Apr 22, 2026
  - Existing-instance init: {url, user, password} prompts + E2E testing (#58, #59)
  - Ship .mcp.json with scaffolded projects so they're testable in Claude Code out of the box (#55, #56)                                                                                                                                                 
  - Add worktree create/remove hook scripts (#57)
@hifi-phil hifi-phil deleted the feat/55-template-mcp-json branch April 27, 2026 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants