@stone-js/mcp-dev 0.8.8 → 0.8.10

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 CHANGED
@@ -27,15 +27,23 @@ npm i -D @stone-js/mcp-dev
27
27
 
28
28
  ## Usage
29
29
 
30
- Add the command to your app with the `@McpDev()` decorator (or register `mcpDevBlueprint`):
31
-
32
- ```ts
33
- import { McpDev } from '@stone-js/mcp-dev'
34
- import { StoneApp } from '@stone-js/core'
35
-
36
- @McpDev()
37
- @StoneApp({ name: 'my-app' })
38
- export class Application {}
30
+ Installing it is the setup. This is dev tooling: the CLI auto-discovers the plugin from your
31
+ devDependencies, which registers `stone mcp` — there is **nothing to declare in `app/`**, no decorator
32
+ and no blueprint, because a development tool has no business in an application's module graph.
33
+
34
+ Configure it, if you want to, in the file that already configures your build:
35
+
36
+ ```js
37
+ // stone.config.mjs
38
+ import { defineBuilderConfig } from '@stone-js/cli'
39
+
40
+ export default defineBuilderConfig({
41
+ mcpDev: {
42
+ name: 'my-app', // the server name your agent sees
43
+ tools: [myOwnTool], // your own tools, defined outside app/
44
+ publishContext: true // default outside production
45
+ }
46
+ })
39
47
  ```
40
48
 
41
49
  ### Register it for your agent
@@ -66,7 +74,7 @@ Or add the entry yourself (Claude Code, Cursor, Claude Desktop, …):
66
74
 
67
75
  ```jsonc
68
76
  { "mcpServers": {
69
- "stone": { "command": "stone", "args": ["mcp"] }
77
+ "stone": { "command": "npx", "args": ["stone", "mcp"] }
70
78
  } }
71
79
  ```
72
80
 
@@ -85,8 +93,8 @@ Or add the entry yourself (Claude Code, Cursor, Claude Desktop, …):
85
93
 
86
94
  ### App-introspection tools
87
95
 
88
- These read *your* app's resolved blueprint (read-only, secrets redacted), so the agent understands
89
- the app you are building, not just the framework:
96
+ These read *your* app's resolved configuration (read-only, secrets redacted), so the agent
97
+ understands the app you are building, not just the framework:
90
98
 
91
99
  | Tool | What it returns |
92
100
  |---|---|
@@ -98,6 +106,46 @@ the app you are building, not just the framework:
98
106
  | `stone_kernel` | The kernel pipeline: event handler, middleware, error handlers. |
99
107
  | `stone_key_routes` | Key-routing definitions (event-bus / realtime): key to handler. |
100
108
  | `stone_config` | A resolved `stone.*` config value by dotted key (secrets redacted); omit the key to list them. |
109
+ | `stone_describes` | Which application the answers above describe, and how the server knows. |
110
+
111
+ #### Which application, exactly
112
+
113
+ `stone mcp` is a console command, so a blueprint it resolves itself is the one a **console** boot
114
+ produces: its adapters, its response type and every platform-conditional contribution belong to a
115
+ different application than the one you run under `stone dev`.
116
+
117
+ The build arranges all of it — nothing is declared in your application:
118
+
119
+ ```bash
120
+ npm i -D @stone-js/mcp-dev
121
+ ```
122
+
123
+ That is the whole setup, and there is deliberately nothing to add to `app/`. Introspection is a
124
+ development concern, so this package is **dev tooling only**: it ships a CLI plugin, the CLI
125
+ auto-discovers first-party plugins from your direct dependencies, and the plugin both registers the
126
+ `stone mcp` command and — on a development build (`dev`, `serve`, `preview`) — injects a hook that
127
+ writes your running app's resolved configuration to `.stone/app-context.json`.
128
+
129
+ Your application never imports this module, never declares it, and a production build carries none of
130
+ it. There is no decorator and no blueprint to activate: a development tool has no business in an
131
+ application's module graph, where it would make a production build depend on a package the app does
132
+ not need.
133
+
134
+ Run `stone dev` once and the agent sees the real thing: the platform you actually run, your adapters,
135
+ your resolved config. Until then the MCP server answers from its own boot and says so through
136
+ `stone_describes`, naming which answers not to trust rather than pretending.
137
+
138
+ Configure it in `stone.config.mjs` under `mcpDev` (server name, instructions, your own tools).
139
+ Opt out of publishing with `mcpDev: { publishContext: false }`: nothing is generated at all,
140
+ rather than code that ships and decides not to run.
141
+
142
+ A file rather than a dev endpoint, deliberately: the Blueprint is assembled once before the first
143
+ event and then read, so publishing it at boot *is* the value, not a snapshot of something moving. It
144
+ also needs no port to discover, adds no route to your application, and works for a CLI or an edge
145
+ context that has no HTTP surface at all.
146
+
147
+ Publishing is on outside production and off in it, since nothing there reads it. Override either way
148
+ with `mcpDev: { publishContext: true | false }`.
101
149
 
102
150
  ### Your own tools
103
151
 
@@ -1,5 +1,5 @@
1
1
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import { McpDevLogger, McpDevOptions, McpToolDef } from './declarations';
2
+ import { McpDevLogger, McpDevOptions, McpToolDef } from './declarations.js';
3
3
  /**
4
4
  * An MCP tool result payload (the SDK content shape).
5
5
  */
@@ -0,0 +1,60 @@
1
+ import { IBlueprint } from '@stone-js/core';
2
+ /** Where a running application leaves its resolved configuration for the MCP server to read. */
3
+ export declare const APP_CONTEXT_FILE: string;
4
+ /**
5
+ * What a running application publishes about itself.
6
+ */
7
+ export interface AppContext {
8
+ /** The platform the application actually booted as. */
9
+ platform?: string;
10
+ /** The environment it booted in. */
11
+ env?: string;
12
+ /** Its name. */
13
+ name?: string;
14
+ /** The resolved `stone` configuration, with secret-looking values redacted. */
15
+ stone: Record<string, unknown>;
16
+ }
17
+ /**
18
+ * A duck-typed reader over a published context, shaped like the blueprint the tools already read.
19
+ *
20
+ * The introspection tools ask questions by dotted key, so a plain object answering `get` is all they
21
+ * need: the same tools then work against a file or against a live blueprint, and neither knows which.
22
+ */
23
+ export interface ContextReader {
24
+ get: <T>(key: string, fallback?: T) => T;
25
+ }
26
+ /**
27
+ * Publish an application's resolved configuration.
28
+ *
29
+ * This is what makes `stone mcp` describe the application a developer is actually running. The MCP
30
+ * server is a console command: booting the app itself gives it the *console* platform, so its
31
+ * adapters, its response type and every platform-conditional contribution belong to a different
32
+ * application than the one under `stone dev`. The running app knows the truth, so the running app
33
+ * says it.
34
+ *
35
+ * A file rather than an endpoint, deliberately. The Blueprint is the Setup dimension: assembled once
36
+ * before the first event and then read, so publishing it once at boot is not a snapshot of something
37
+ * moving — it *is* the value. A file also needs no port to discover, no dev-only route in someone's
38
+ * application, no token to protect, and it works for a CLI or an edge context that has no HTTP
39
+ * surface at all. What genuinely moves at run time (a `live` configuration, metrics) is a different
40
+ * question, and belongs to a different tool.
41
+ *
42
+ * @param blueprint - The running application's blueprint.
43
+ * @param cwd - The project root.
44
+ * @returns The file it wrote.
45
+ */
46
+ export declare function publishAppContext(blueprint: IBlueprint, cwd?: string): string;
47
+ /**
48
+ * Read what a running application published, if it published anything.
49
+ *
50
+ * @param cwd - The project root.
51
+ * @returns The context, or `undefined` when no application has run.
52
+ */
53
+ export declare function readAppContext(cwd?: string): AppContext | undefined;
54
+ /**
55
+ * A reader over a published context, answering the same dotted keys a blueprint answers.
56
+ *
57
+ * @param context - The published context.
58
+ * @returns The reader.
59
+ */
60
+ export declare function contextReader(context: AppContext): ContextReader;
package/dist/cli.d.ts ADDED
@@ -0,0 +1,53 @@
1
+ import { BlueprintContext, ClassType, IBlueprint, NextMiddleware } from '@stone-js/core';
2
+ import type { StoneCliPlugin, StonePluginBlueprintMiddleware } from '@stone-js/cli';
3
+ /**
4
+ * Register the `mcp` command on the CLI.
5
+ *
6
+ * Contributed by the plugin rather than by the application, which is the whole point: introspection is
7
+ * a development concern, and an application should not have to declare a development tool to get one.
8
+ * The CLI runs plugin blueprint middleware in its own pipeline, and the CLI is itself a Stone.js app on
9
+ * the console platform, so the command lands exactly where every other command does.
10
+ *
11
+ * @param context - The blueprint context.
12
+ * @param next - The next middleware.
13
+ * @returns The blueprint.
14
+ */
15
+ export declare const SetMcpCommandsMiddleware: (context: BlueprintContext<IBlueprint, ClassType>, next: NextMiddleware<BlueprintContext<IBlueprint, ClassType>, IBlueprint>) => Promise<IBlueprint>;
16
+ /** The blueprint middleware this plugin contributes. */
17
+ export declare const mcpDevPluginMiddleware: StonePluginBlueprintMiddleware[];
18
+ /** Where the plugin writes the module it injects, relative to the build's `.stone/tmp` directory. */
19
+ export declare const GENERATED_MODULE: string;
20
+ /** The commands that mean "a developer is working right now", and nothing else. */
21
+ export declare const DEV_COMMANDS: string[];
22
+ /**
23
+ * The module injected into a development build.
24
+ *
25
+ * It contributes one lifecycle hook, and imports the publishing helper from the package rather than
26
+ * restating it, so the file format and the redaction rules keep living in one place.
27
+ *
28
+ * @returns The generated module's source.
29
+ */
30
+ export declare function generatedModule(): string;
31
+ /**
32
+ * The MCP dev CLI plugin.
33
+ *
34
+ * Introspection is a development concern, so it belongs to the build rather than to the application.
35
+ * Declaring it in the app would put a development tool in the application's own module graph — and
36
+ * make a production build depend on a package the application does not need — for a feature nobody
37
+ * uses in production. The build already knows when a developer is working, which is exactly when this
38
+ * is wanted, so the build is where it is decided.
39
+ *
40
+ * What it does, in one sentence: on a development build it injects a hook that makes the running
41
+ * application publish its resolved configuration, so `stone mcp` describes **that** application
42
+ * instead of the console boot it can reach by itself.
43
+ *
44
+ * Nothing is injected into a production build, and nothing has to be imported by the app.
45
+ *
46
+ * @returns The plugin.
47
+ */
48
+ export declare function mcpDevCliPlugin(): StoneCliPlugin;
49
+ /**
50
+ * A ready-to-use plugin instance, used by first-party `package.json` auto-discovery.
51
+ */
52
+ declare const plugin: StoneCliPlugin;
53
+ export default plugin;