@stone-js/mcp-dev 0.8.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,29 @@
1
+ import { IBlueprint } from '@stone-js/core';
2
+ import { McpToolDef } from './declarations';
3
+ /**
4
+ * Best-effort name of a module reference (class, function, or meta-module `{ module }`).
5
+ *
6
+ * @param value - The reference to name.
7
+ * @returns The resolved name.
8
+ */
9
+ export declare function moduleName(value: unknown): string;
10
+ /**
11
+ * Produce a JSON-safe, secret-redacted copy of a config value: functions/classes become a label,
12
+ * `RegExp` its source, secret-looking keys `[redacted]`, and recursion is depth-capped.
13
+ *
14
+ * @param value - The value to sanitize.
15
+ * @param depth - The current recursion depth.
16
+ * @returns A serializable value.
17
+ */
18
+ export declare function sanitize(value: unknown, depth?: number): unknown;
19
+ /**
20
+ * Build the read-only introspection tools bound to the app's resolved blueprint.
21
+ *
22
+ * These expose what the app actually declares (routes, commands, adapters, providers, kernel
23
+ * pipeline, config) so a coding agent understands *this* app, not just the framework. They read
24
+ * only, never mutate, and redact secret-looking config values.
25
+ *
26
+ * @param blueprint - The resolved application blueprint.
27
+ * @returns The introspection tools.
28
+ */
29
+ export declare function createIntrospectionTools(blueprint: IBlueprint): McpToolDef[];
@@ -0,0 +1,24 @@
1
+ import { Concept, KnowledgeBase } from './declarations';
2
+ /**
3
+ * The single, curated, machine-readable map of Stone.js. Kept concise and accurate so an agent
4
+ * can consult it in real time instead of scanning every package.
5
+ */
6
+ export declare const knowledgeBase: KnowledgeBase;
7
+ /**
8
+ * Find a concept by id (case-insensitive).
9
+ *
10
+ * @param id - The concept id.
11
+ * @returns The concept, or undefined.
12
+ */
13
+ export declare function getConcept(id: string): Concept | undefined;
14
+ /**
15
+ * Full-text search across concepts, modules, best-practices and gaps.
16
+ *
17
+ * @param query - The search terms.
18
+ * @returns Matching entries with their kind.
19
+ */
20
+ export declare function searchKnowledge(query: string): Array<{
21
+ kind: string;
22
+ title: string;
23
+ text: string;
24
+ }>;
package/dist/llms.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ import { KnowledgeBase } from './declarations';
2
+ /**
3
+ * Generates the concise `llms.txt` index (the emerging standard: a short, link-friendly Markdown
4
+ * map an agent can read in one shot). Serve it at `/llms.txt` from the docs site.
5
+ *
6
+ * @param base - The knowledge base (defaults to the built-in one).
7
+ * @returns The `llms.txt` content.
8
+ */
9
+ export declare function generateLlmsTxt(base?: KnowledgeBase): string;
10
+ /**
11
+ * Generates the fuller `llms-full.txt` (adds best-practices and known gaps) — the complete brief
12
+ * for an agent building with Stone.js.
13
+ *
14
+ * @param base - The knowledge base (defaults to the built-in one).
15
+ * @returns The `llms-full.txt` content.
16
+ */
17
+ export declare function generateLlmsFullTxt(base?: KnowledgeBase): string;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Injectable filesystem surface, so `.mcp.json` handling stays testable.
3
+ */
4
+ export interface McpJsonIo {
5
+ exists: (path: string) => boolean;
6
+ read: (path: string) => string;
7
+ write: (path: string, content: string) => void;
8
+ }
9
+ /**
10
+ * The `.mcp.json` server entry that launches this dev server.
11
+ *
12
+ * @param command - The launcher command (defaults to `stone`).
13
+ * @returns The MCP server entry.
14
+ */
15
+ export declare function mcpServerEntry(command?: string): {
16
+ command: string;
17
+ args: string[];
18
+ };
19
+ /**
20
+ * Merge the `stone` server into an existing `.mcp.json` object without clobbering anything.
21
+ *
22
+ * It only adds the `stone` entry when absent, so a developer's own config (other servers, or a
23
+ * customized `stone` entry) is preserved.
24
+ *
25
+ * @param existing - The parsed `.mcp.json` (or undefined when the file does not exist).
26
+ * @returns The merged config and whether it changed.
27
+ */
28
+ export declare function mergeMcpJson(existing: Record<string, unknown> | undefined): {
29
+ config: Record<string, unknown>;
30
+ changed: boolean;
31
+ };
32
+ /**
33
+ * Create or update `.mcp.json` at `cwd` so a coding agent discovers this server. Idempotent: it
34
+ * writes only when the `stone` entry is missing, and never overwrites the rest of the file.
35
+ *
36
+ * @param cwd - The project root.
37
+ * @param io - The filesystem surface (defaults to `node:fs`).
38
+ * @returns The file path and whether it was written.
39
+ */
40
+ export declare function initMcpJson(cwd: string, io?: McpJsonIo): {
41
+ file: string;
42
+ changed: boolean;
43
+ };
44
+ /**
45
+ * Whether a `.mcp.json` exists at `cwd`.
46
+ *
47
+ * @param cwd - The project root.
48
+ * @param io - The filesystem surface (defaults to `node:fs`).
49
+ * @returns True when the file exists.
50
+ */
51
+ export declare function hasMcpJson(cwd: string, io?: McpJsonIo): boolean;
@@ -0,0 +1,17 @@
1
+ import { BlueprintContext, IBlueprint, ClassType, MetaMiddleware, NextMiddleware } from '@stone-js/core';
2
+ /**
3
+ * Middleware that registers the `mcp` command when the app runs on the Node CLI adapter.
4
+ *
5
+ * It mirrors the router's command registration: contribute a `MetaCommandHandler` to
6
+ * `stone.adapter.commands` so the CLI (itself a Stone.js app on the Node CLI adapter) discovers
7
+ * `stone mcp` by introspection, no hard-coding.
8
+ *
9
+ * @param context - The blueprint context.
10
+ * @param next - The next pipeline function.
11
+ * @returns The updated blueprint.
12
+ */
13
+ export declare const SetMcpCommandsMiddleware: (context: BlueprintContext<IBlueprint, ClassType>, next: NextMiddleware<BlueprintContext<IBlueprint, ClassType>, IBlueprint>) => Promise<IBlueprint>;
14
+ /**
15
+ * The blueprint middleware contributed by the MCP dev module.
16
+ */
17
+ export declare const metaMcpDevBlueprintMiddleware: Array<MetaMiddleware<BlueprintContext<IBlueprint, ClassType>, IBlueprint>>;
@@ -0,0 +1,34 @@
1
+ import { McpDevOptions } from '../declarations';
2
+ import { AppConfig, StoneBlueprint } from '@stone-js/core';
3
+ /**
4
+ * MCP dev configuration bucket (`stone.mcpDev`).
5
+ */
6
+ export interface McpDevConfig extends McpDevOptions {
7
+ }
8
+ /**
9
+ * Application config augmented with the MCP dev bucket.
10
+ */
11
+ export interface McpDevAppConfig extends Partial<AppConfig> {
12
+ mcpDev: Partial<McpDevConfig>;
13
+ }
14
+ /**
15
+ * Blueprint for the MCP dev module.
16
+ */
17
+ export interface McpDevBlueprint extends StoneBlueprint {
18
+ stone: McpDevAppConfig;
19
+ }
20
+ /**
21
+ * Opt-in blueprint: import and register it to add the `stone mcp` command.
22
+ *
23
+ * It contributes a blueprint middleware that registers the command on the Node CLI adapter. Add
24
+ * your own tools and the server name/instructions under `stone.mcpDev` (or via `@McpDev()` /
25
+ * `defineMcpDev()`).
26
+ */
27
+ export declare const mcpDevBlueprint: McpDevBlueprint;
28
+ /**
29
+ * Imperative helper: build an MCP dev blueprint with the given options.
30
+ *
31
+ * @param options - The MCP dev options (server name, instructions, your tools, report tools).
32
+ * @returns The blueprint to register in your app.
33
+ */
34
+ export declare function defineMcpDev(options?: McpDevOptions): McpDevBlueprint;
@@ -0,0 +1,15 @@
1
+ import { McpToolDef, ReportToolsOptions } from './declarations';
2
+ /**
3
+ * The Stone.js framework-knowledge tools served by `stone mcp`. They are registered on the MCP
4
+ * server automatically; point your coding agent at it and it can query the framework in real time
5
+ * (concepts, modules, best-practices, gaps) instead of scanning every package.
6
+ */
7
+ export declare const stoneMcpTools: McpToolDef[];
8
+ /**
9
+ * Creates tools that let an agent (or the developer through it) report a bug or request a feature
10
+ * as a real GitHub issue, straight from the dev loop.
11
+ *
12
+ * @param options - The GitHub token and target repository.
13
+ * @returns The report tools.
14
+ */
15
+ export declare function createReportTools(options: ReportToolsOptions): McpToolDef[];
package/package.json ADDED
@@ -0,0 +1,98 @@
1
+ {
2
+ "name": "@stone-js/mcp-dev",
3
+ "version": "0.8.0",
4
+ "description": "Serve Stone.js's knowledge to your coding agent. A single `stone mcp` command starts an MCP server (stdio) exposing the framework's concepts, modules and best-practices plus your own tools, so the LLM masters the context while you master the domain.",
5
+ "author": "Mr. Stone <evensstone@gmail.com>",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/stone-foundation/stone-js-framework.git",
10
+ "directory": "stone-js-mcp-dev"
11
+ },
12
+ "homepage": "https://stonejs.dev",
13
+ "bugs": {
14
+ "url": "https://github.com/stone-foundation/stone-js-framework/issues"
15
+ },
16
+ "keywords": [
17
+ "StoneJS",
18
+ "mcp",
19
+ "cli",
20
+ "ai",
21
+ "agent",
22
+ "llm",
23
+ "llms.txt",
24
+ "agentic",
25
+ "knowledge"
26
+ ],
27
+ "files": [
28
+ "/dist",
29
+ "/skills"
30
+ ],
31
+ "type": "module",
32
+ "sideEffects": false,
33
+ "types": "./dist/index.d.ts",
34
+ "exports": {
35
+ ".": {
36
+ "browser": {
37
+ "types": "./dist/index.d.ts",
38
+ "default": "./dist/browser.js"
39
+ },
40
+ "default": {
41
+ "types": "./dist/index.d.ts",
42
+ "default": "./dist/index.js"
43
+ }
44
+ }
45
+ },
46
+ "engines": {
47
+ "node": ">=18.17.0"
48
+ },
49
+ "peerDependencies": {
50
+ "@stone-js/core": "0.8.0"
51
+ },
52
+ "dependencies": {
53
+ "@modelcontextprotocol/sdk": "^1.29.0"
54
+ },
55
+ "devDependencies": {
56
+ "@commitlint/cli": "^19.8.1",
57
+ "@commitlint/config-conventional": "^19.8.1",
58
+ "@rollup/plugin-commonjs": "^28.0.6",
59
+ "@rollup/plugin-multi-entry": "^6.0.1",
60
+ "@rollup/plugin-node-resolve": "^16.0.1",
61
+ "@rollup/plugin-typescript": "^12.1.4",
62
+ "@types/node": "^24.0.7",
63
+ "@vitest/coverage-v8": "^3.2.4",
64
+ "husky": "^9.1.7",
65
+ "rimraf": "^6.0.1",
66
+ "rollup": "^4.44.1",
67
+ "rollup-plugin-node-externals": "^8.0.1",
68
+ "ts-standard": "^12.0.2",
69
+ "tslib": "^2.8.1",
70
+ "typedoc": "^0.28.6",
71
+ "typedoc-plugin-markdown": "^4.7.0",
72
+ "typescript": "^5.6.3",
73
+ "vitest": "^3.2.4"
74
+ },
75
+ "ts-standard": {
76
+ "globals": [
77
+ "it",
78
+ "test",
79
+ "vi",
80
+ "expect",
81
+ "describe",
82
+ "beforeEach"
83
+ ]
84
+ },
85
+ "scripts": {
86
+ "lint": "ts-standard src",
87
+ "lint:fix": "ts-standard --fix src tests",
88
+ "predoc": "rimraf docs",
89
+ "doc": "typedoc",
90
+ "clean": "rimraf dist",
91
+ "build": "rollup -c",
92
+ "test": "vitest run",
93
+ "test:cvg": "npm run test -- --coverage",
94
+ "test:text": "npm run test:cvg -- --coverage.reporter=text",
95
+ "test:html": "npm run test:cvg -- --coverage.reporter=html",
96
+ "test:clover": "npm run test:cvg -- --coverage.reporter=clover"
97
+ }
98
+ }
@@ -0,0 +1,31 @@
1
+ # Stone.js Agent Skills
2
+
3
+ These are [Agent Skills](https://agentskills.io) for building Stone.js apps: portable folders, each
4
+ with a `SKILL.md` (name, description, instructions), that a skills-compatible agent (Claude Code,
5
+ Cursor, Copilot, Gemini CLI, OpenCode, Goose, …) loads on demand via progressive disclosure. They
6
+ are the framework's conventions, packaged so the agent applies them without you re-explaining them.
7
+
8
+ They pair with the `stone mcp` server: the skills tell the agent *how* to build with Stone.js, and
9
+ the `stone_*` MCP tools let it introspect *this* app (routes, commands, adapters, config) in real
10
+ time.
11
+
12
+ ## Skills
13
+
14
+ | Skill | Use it when |
15
+ |---|---|
16
+ | `stone-js` | Writing, structuring, or reviewing any Stone.js app (the core model + conventions). |
17
+ | `stone-js-routing` | Adding or changing routes, controllers, or HTTP endpoints. |
18
+ | `stone-js-adapters` | Choosing where the app runs or adding a deploy target. |
19
+
20
+ ## Install
21
+
22
+ Skills are read from your agent's skills directory. Copy (or symlink) the ones you want:
23
+
24
+ ```bash
25
+ # Claude Code (project scope)
26
+ mkdir -p .claude/skills
27
+ cp -R node_modules/@stone-js/mcp-dev/skills/stone-js* .claude/skills/
28
+ ```
29
+
30
+ Other agents use their own directory (`.cursor/skills`, `.github/skills`, …); see your agent's
31
+ docs. Each skill is a self-contained folder, so copying the folder is all that is needed.
@@ -0,0 +1,63 @@
1
+ ---
2
+ name: stone-js
3
+ description: Use when writing, structuring, or reviewing a Stone.js (@stone-js/*) application. Covers the Continuum model, StoneApp bootstrapping, the declarative/imperative paradigms, the three module forms, and blueprint configuration. Pair with the `stone_*` MCP tools from @stone-js/mcp-dev to introspect the live app.
4
+ ---
5
+
6
+ # Building with Stone.js
7
+
8
+ Stone.js is the reference implementation of the Continuum Architecture: an application is an
9
+ **act**, `Application = Domain × Context → Resolution`. You write your domain once; the context
10
+ (runtime, protocol, caller) applies to it at run time. Stone.js *is* the context.
11
+
12
+ ## Golden rules
13
+
14
+ - **The domain never imports the platform.** No HTTP/CLI/browser vocabulary leaks into domain code.
15
+ A handler receives an `IncomingEvent` and returns a value; the adapter and kernel do the rest.
16
+ - **Two paradigms, at parity.**
17
+ - *Declarative*: TC39 **stage-3** decorators (`@StoneApp`, `@Routing`, `@Get`, …) with
18
+ `Symbol.metadata`. **Never** use `reflect-metadata` or `experimentalDecorators`.
19
+ - *Imperative*: `define*` helpers producing meta-modules `{ module, isClass?, isFactory? }`.
20
+ - **Three forms everywhere**: class, factory, and function. The **function form never receives the
21
+ container**; **providers forbid the function form**.
22
+ - **All configuration lives on the Blueprint under dotted `stone.*` keys.** It is built once, before
23
+ any event, by introspecting decorators or by imperative meta-modules.
24
+ - Constructors are **private/protected**; expose a `static create()`.
25
+ - ESM only (`"type": "module"`), TypeScript strict, `ts-standard` lint, Vitest (aim for 100%),
26
+ conventional commits.
27
+
28
+ ## A minimal app
29
+
30
+ ```ts
31
+ import { StoneApp, IncomingEvent } from '@stone-js/core'
32
+ import { Routing, Get } from '@stone-js/router'
33
+
34
+ @Routing()
35
+ @StoneApp({ name: 'my-app' })
36
+ class Application {
37
+ @Get('/hello')
38
+ hello (event: IncomingEvent) {
39
+ return { message: `Hello ${event.get<string>('name', 'world')}` }
40
+ }
41
+ }
42
+ ```
43
+
44
+ The same class can be served over HTTP, in a Lambda, in the browser, or on the edge: you change the
45
+ **adapter**, not the domain. See the `stone-js-adapters` skill.
46
+
47
+ ## Workflow
48
+
49
+ 1. **Before writing code, query the framework.** Call the `stone_search`, `stone_concept`,
50
+ `stone_modules`, and `stone_docs` MCP tools (served by `stone mcp`) to confirm the current
51
+ conventions and the right module for the job, instead of guessing from generic Node knowledge.
52
+ 2. **Inspect the app** with `stone_app`, `stone_routes`, `stone_commands`, `stone_adapters`,
53
+ `stone_providers`, `stone_kernel`, and `stone_config` to see what it actually declares.
54
+ 3. Reach for an official module rather than re-implementing: validation, auth, authz, resources,
55
+ openapi, testing, realtime, event-bus, queue, cache. Declare internal deps as `workspace:*`.
56
+ 4. **Every bug fix earns a behavioral test** (exercise real behavior, not mocks).
57
+
58
+ ## Anti-patterns to reject
59
+
60
+ - Importing `reflect-metadata` or enabling `experimentalDecorators`.
61
+ - Putting HTTP/CLI specifics in the core/domain.
62
+ - Passing the container to a function-form module, or using a function-form provider.
63
+ - Storing durable content in a module's `docs/` folder (it is TypeDoc output, wiped each build).
@@ -0,0 +1,57 @@
1
+ ---
2
+ name: stone-js-adapters
3
+ description: Use when choosing where a Stone.js app runs or adding a deploy target (Node HTTP, AWS Lambda, browser SPA, edge/WinterCG, CLI). Explains the "build once, deploy anywhere" model, how an adapter turns a platform cause into an IncomingEvent, and how the runtime collapse selects an adapter. Inspect targets with the `stone_adapters` MCP tool.
4
+ ---
5
+
6
+ # Adapters: build once, deploy anywhere
7
+
8
+ An adapter is the **Integration** dimension of the Continuum: it captures a raw platform *cause*,
9
+ normalizes it into an *intention* (`IncomingEvent`), lets the kernel apply the domain, then turns
10
+ the response back into a native *effect*. The domain and routes never change; you add or switch an
11
+ adapter.
12
+
13
+ ## The adapters
14
+
15
+ | Target | Package |
16
+ |---|---|
17
+ | Node HTTP server | `@stone-js/node-http-adapter` |
18
+ | AWS Lambda (generic / HTTP) | `@stone-js/aws-lambda-adapter`, `@stone-js/aws-lambda-http-adapter` |
19
+ | Web standard / edge (Cloudflare, Deno, Bun, Vercel, Netlify) | `@stone-js/fetch-adapter`, `@stone-js/edge-adapter` |
20
+ | Browser SPA | `@stone-js/browser-adapter` |
21
+ | CLI | `@stone-js/node-cli-adapter` |
22
+
23
+ Enable one by adding its decorator/blueprint to the app (e.g. `@NodeHttp()`), alongside `@StoneApp`
24
+ and `@Routing`.
25
+
26
+ ```ts
27
+ import { NodeHttp } from '@stone-js/node-http-adapter'
28
+ import { Routing } from '@stone-js/router'
29
+ import { StoneApp } from '@stone-js/core'
30
+
31
+ @NodeHttp()
32
+ @Routing()
33
+ @StoneApp({ name: 'my-app' })
34
+ class Application {}
35
+ ```
36
+
37
+ ## How selection works (the runtime collapse)
38
+
39
+ When several adapters are registered, the kernel selects one per invocation, in order: a single
40
+ adapter wins outright; else the one marked `current: true`; else a match on `stone.adapter.platform`;
41
+ else a match on `alias`; else the one marked `default: true`. So one build can target many
42
+ platforms, and the environment decides which context applies.
43
+
44
+ ## Rules
45
+
46
+ - Never leak a platform's request/response object into the domain; the adapter is the only place
47
+ that speaks the platform's dialect.
48
+ - An adapter's job is Integration **only**: cause to `IncomingEvent`, and response to effect. It
49
+ must not own routing or a dispatcher; the kernel routes.
50
+ - CLI commands are contributed by modules to `stone.adapter.commands` and discovered by the CLI
51
+ through introspection (that is how `stone mcp` itself is added by `@stone-js/mcp-dev`).
52
+
53
+ ## Verify with the MCP tools
54
+
55
+ Call `stone_adapters` to list registered adapters (platform, alias, default/current) and the active
56
+ platform. Use `stone_app` for a quick summary, and `stone_docs` for the adapter guides. `stone_search`
57
+ the knowledge base when picking a target or debugging selection.
@@ -0,0 +1,66 @@
1
+ ---
2
+ name: stone-js-routing
3
+ description: Use when adding or changing routes, controllers, or HTTP endpoints in a Stone.js app with @stone-js/router. Covers the routing decorators, controllers, route groups, middleware, and the universal (node/browser) router. Verify live routes with the `stone_routes` MCP tool.
4
+ ---
5
+
6
+ # Routing in Stone.js
7
+
8
+ `@stone-js/router` is a universal router (node and browser). Enable it on the app with `@Routing()`,
9
+ then declare routes with decorators or imperative definitions. Routing is platform-agnostic: the
10
+ same routes answer over any HTTP adapter.
11
+
12
+ ## Route handlers on the app
13
+
14
+ ```ts
15
+ import { Routing, Get, Post } from '@stone-js/router'
16
+ import { StoneApp, IncomingEvent } from '@stone-js/core'
17
+
18
+ @Routing()
19
+ @StoneApp({ name: 'my-app' })
20
+ class Application {
21
+ @Get('/users')
22
+ list () { return this.service.all() }
23
+
24
+ @Post('/users')
25
+ create (event: IncomingEvent) { return this.service.create(event.get('body')) }
26
+ }
27
+ ```
28
+
29
+ ## Controllers and groups
30
+
31
+ Group related routes on a controller with `@Controller('/prefix')`, then `@Get`, `@Post`, `@Put`,
32
+ `@Patch`, `@Delete`, `@Options`, `@Any`, or `@Match`. `@Page` declares a view/component route.
33
+
34
+ ```ts
35
+ import { Controller, Get } from '@stone-js/router'
36
+
37
+ @Controller('/api/users')
38
+ class UserController {
39
+ @Get('/') // GET /api/users
40
+ index () { /* ... */ }
41
+
42
+ @Get('/:id') // GET /api/users/:id
43
+ show (event: IncomingEvent) { return this.repo.find(event.get('params').id) }
44
+ }
45
+ ```
46
+
47
+ ## Key points
48
+
49
+ - A handler returns a plain value; the response is built by the layers, not by you.
50
+ - Bind path params, apply per-route `middleware`, set `rules` (param regexps), `defaults`, and
51
+ `bindings` on the route definition; all are introspectable.
52
+ - The router is also the app's kernel event handler when `@Routing()` is set.
53
+ - Prefer decorators, but the imperative form (route definitions under `stone.router.definitions`)
54
+ is available and equivalent.
55
+
56
+ ## Verify with the MCP tools
57
+
58
+ After adding routes, call `stone_routes` to confirm the resolved tree (path, methods, name,
59
+ handler, middleware). Use `stone_kernel` to see the middleware pipeline that every route traverses.
60
+ When unsure of an option, `stone_search` the knowledge base or `stone_docs` for the routing guide.
61
+
62
+ ## Do not
63
+
64
+ - Do not read the request/response as platform objects in a handler; use the `IncomingEvent` API.
65
+ - Do not hand-roll URL parsing or a second router; the framework's matchers handle host, method,
66
+ protocol, and URI.