@haibun/mcp 1.68.0 → 1.70.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 (34) hide show
  1. package/README.md +66 -137
  2. package/build/lib/http-prompter-client.d.ts +19 -0
  3. package/build/lib/http-prompter-client.d.ts.map +1 -0
  4. package/build/lib/http-prompter-client.js +68 -0
  5. package/build/lib/http-prompter-client.js.map +1 -0
  6. package/build/lib/mcp-executor-server.d.ts +11 -3
  7. package/build/lib/mcp-executor-server.d.ts.map +1 -1
  8. package/build/lib/mcp-executor-server.js +132 -1
  9. package/build/lib/mcp-executor-server.js.map +1 -1
  10. package/build/mcp-client-stepper.d.ts +24 -13
  11. package/build/mcp-client-stepper.d.ts.map +1 -1
  12. package/build/mcp-client-stepper.js +251 -58
  13. package/build/mcp-client-stepper.js.map +1 -1
  14. package/build/mcp-server-stepper.d.ts +4 -3
  15. package/build/mcp-server-stepper.d.ts.map +1 -1
  16. package/build/mcp-server-stepper.js +28 -3
  17. package/build/mcp-server-stepper.js.map +1 -1
  18. package/build/mcp-test-utils.d.ts +3 -4
  19. package/build/mcp-test-utils.d.ts.map +1 -1
  20. package/build/mcp-test-utils.js +6 -5
  21. package/build/mcp-test-utils.js.map +1 -1
  22. package/package.json +3 -3
  23. package/build/lib/mcp-stepper-server.d.ts +0 -13
  24. package/build/lib/mcp-stepper-server.d.ts.map +0 -1
  25. package/build/lib/mcp-stepper-server.js +0 -91
  26. package/build/lib/mcp-stepper-server.js.map +0 -1
  27. package/build/mcp-test-stepper.d.ts +0 -9
  28. package/build/mcp-test-stepper.d.ts.map +0 -1
  29. package/build/mcp-test-stepper.js +0 -20
  30. package/build/mcp-test-stepper.js.map +0 -1
  31. package/build/test-constants.d.ts +0 -10
  32. package/build/test-constants.d.ts.map +0 -1
  33. package/build/test-constants.js +0 -14
  34. package/build/test-constants.js.map +0 -1
package/README.md CHANGED
@@ -2,163 +2,92 @@
2
2
 
3
3
  Enables agents to interact with Haibun steppers through the standardized [Model Context Protocol (MCP)](https://modelcontextprotocol.io/).
4
4
 
5
- This module provides both server and client capabilities for MCP integration with Haibun.
6
-
7
- ## MCP Server
8
-
9
- The **MCP Server** automatically exposes all available Haibun steppers as MCP tools, allowing external agents to:
10
-
11
- - **Discover available steppers** through MCP's tool listing protocol
12
- - **Execute any stepper functionality** available in your workspace
13
-
14
- ### Remote Execution Support
15
-
16
- The MCP server can connect to a remote Haibun execution context via HTTP. This is particularly useful when:
17
-
18
- - You want to pause execution and interact via an IDE or other tools
19
- - Multiple agents need to share the same execution context
20
-
21
- #### Configuration
22
-
23
- ⚠️ **Security Requirement**: ACCESS_TOKEN is mandatory when enabling remote execution. The system will fail fast if a port is configured without proper authentication.
24
-
25
- To enable remote execution, configure both the HTTP executor and MCP server with matching ports and tokens:
5
+ ## Quick Start
26
6
 
7
+ ### 1. Run exampe external HTTP executor
27
8
  ```bash
28
- # Start Haibun with remote executor enabled and access token
29
- HAIBUN_O_WEBPLAYWRIGHT_STORAGE=StorageMem \
30
- HAIBUN_O_HTTPEXECUTORSTEPPER_LISTEN_PORT=8124 \
31
- HAIBUN_O_HTTPEXECUTORSTEPPER_ACCESS_TOKEN=your-secret-token \
32
- node modules/cli/build/cli.js --cwd modules/mcp/runtime cli
33
- ```
34
9
 
35
- If you want the MCP server to connect to a remote execution endpoint, configure it explicitly:
10
+ ./run-mcp-with-monitor.sh
36
11
 
37
- ```bash
38
- # Configure MCP server to use remote execution
39
- HAIBUN_O_MCPSERVERSTEPPER_REMOTE_PORT=8124 \
40
- HAIBUN_O_MCPSERVERSTEPPER_ACCESS_TOKEN=your-secret-token \
41
- node modules/cli/build/cli.js --cwd modules/mcp/test tests
42
12
  ```
43
- #### Remote Execution API
44
-
45
- When the HTTP executor is running, you can interact with it directly via HTTP API. All requests require authentication via the ACCESS_TOKEN.
46
13
 
47
- **Execute a step:**
48
- ```bash
49
- curl -X POST http://localhost:8124/execute-step \
50
- -H "Content-Type: application/json" \
51
- -H "Authorization: Bearer your-secret-token" \
52
- -d '{
53
- "statement": "I set MY_VAR to hello world",
54
- "source": "curl"
55
- }'
14
+ ### 2. VS Code MCP Configuration
15
+ Add to your VS Code `mcp.json`:
16
+ ```json
17
+ {
18
+ "servers": {
19
+ "haibun-mcp": {
20
+ "type": "stdio",
21
+ "command": "node",
22
+ "cwd": "/path/to/haibun",
23
+ "args": [
24
+ "modules/cli/build/cli.js",
25
+ "-c",
26
+ "./modules/mcp/runtime/agent/config.json",
27
+ "./modules/mcp/runtime/agent"
28
+ ],
29
+ "env": {
30
+ "HAIBUN_O_WEBPLAYWRIGHT_STORAGE": "StorageMem",
31
+ "HAIBUN_O_MCPSERVERSTEPPER_REMOTE_PORT": "8125",
32
+ "HAIBUN_O_MCPSERVERSTEPPER_ACCESS_TOKEN": "localTest"
33
+ }
34
+ }
35
+ }
36
+ }
56
37
  ```
57
38
 
58
- ### Starting an MCP Server
39
+ ### 3. Use MCP Tools
40
+ Available tools automatically expose all Haibun steppers:
41
+ - `WebPlaywright-gotoPage` - Navigate to web pages
42
+ - `WebPlaywright-click` - Click elements
43
+ - `WebPlaywright-shouldSeeText` - Verify page content
44
+ - `VariablesStepper-set` - Set variables
45
+ - `Haibun-pauseSeconds` - Add delays
46
+ - And all other loaded steppers
59
47
 
60
- The MCP Server is a Haibun stepper. For a basic example with representative steppers:
48
+ ## Architecture
61
49
 
62
- ```bash
63
- # Basic local execution
64
- HAIBUN_O_WEBPLAYWRIGHT_STORAGE=StorageMem \
65
- node modules/cli/build/cli.js --cwd modules/mcp/runtime local
66
- ```
50
+ **External Runtime**
51
+ - Runs HTTP executor with monitoring
52
+ - Provides step execution API on port 8125
53
+ - Browser automation visible in monitor
54
+
55
+ **MCP Agent**
56
+ - Lightweight process that connects to external runtime
57
+ - Exposes remote steppers as MCP tools via stdio
58
+ - Acts as bridge between eg VS Code and your tests
67
59
 
68
- Or with remote execution enabled:
60
+ ## Advanced Usage
69
61
 
62
+ ### Local MCP Server (no external runtime)
70
63
  ```bash
71
- # With remote execution capability
72
64
  HAIBUN_O_WEBPLAYWRIGHT_STORAGE=StorageMem \
73
- HAIBUN_O_HTTPEXECUTORSTEPPER_LISTEN_PORT=8124 \
74
- HAIBUN_O_HTTPEXECUTORSTEPPER_ACCESS_TOKEN=your-secret-token \
75
- node modules/cli/build/cli.js --cwd modules/mcp/runtime http
65
+ node modules/cli/build/cli.js -c ./modules/mcp/runtime/config.json ./modules/mcp/runtime/local
76
66
  ```
77
67
 
78
- ### Using from External MCP Clients
79
- Any MCP-compatible client can discover and call the exposed tools. The exact tools available depend on which Haibun modules are configured in your workspace.
80
-
81
- ### Server Control from Haibun Features
82
- ```gherkin
83
- Feature: MCP Server Management
84
- Scenario: Start and stop MCP server
85
- Given I serve mcp tools from steppers
86
-
87
- The server is now running and exposing tools to external MCP clients.
88
-
89
- When I stop mcp tools
90
- The server is stopped.
91
-
92
- Scenario: Enable remote execution API
93
- Given I enable remote executor
94
-
95
- Now external MCP servers can connect to this execution context via HTTP.
68
+ ### HTTP API Direct Access
69
+ ```bash
70
+ curl -X POST http://localhost:8125/execute-step \
71
+ -H "Authorization: Bearer localTest" \
72
+ -H "Content-Type: application/json" \
73
+ -d '{"statement": "pause for 1s", "source": "/api"}'
96
74
  ```
97
75
 
98
- ## MCP Client
99
-
100
- The **MCP Client** allows Haibun features to connect to external MCP servers and discover their available tools.
101
-
102
- ### Client Usage from Haibun Features
76
+ ### Control from Haibun Features
103
77
  ```gherkin
104
- Feature: External MCP Integration
105
- Scenario: List tools from external server
106
- When I list mcp tools
78
+ Start MCP server.
79
+ serve mcp tools from steppers
107
80
 
108
- This discovers all tools available from the configured MCP server.
109
- ```
110
-
111
- ### Client Configuration
112
- The client requires server connection parameters to be configured via module options:
113
- ```json
114
- {
115
- "MCPClientStepper": {
116
- "SERVER": "{\"command\": \"node\", \"args\": [\"server.js\"], \"env\": {}}"
117
- }
118
- }
81
+ Enable remote execution.
82
+ enable remote executor
119
83
  ```
120
84
 
121
- ## Examples
85
+ ## Configuration
122
86
 
123
- ## VSCode config
124
-
125
- ```
126
- "mcp": {
127
- "servers": {
128
- "haibun-mcp": {
129
- "type": "stdio",
130
- "command": "tsx",
131
- "cwd": "~",
132
- "args": [
133
- "modules/cli/build/cli.js",
134
- "-c",
135
- "./modules/mcp/runtime/config.json",
136
- "./modules/mcp/runtime/http"
137
- ],
138
- "env": {
139
- "HAIBUN_O_MCPSERVERSTEPPER_REMOTE_PORT": "8125",
140
- "HAIBUN_O_MCPSERVERSTEPPER_ACCESS_TOKEN": "some-great-password",
141
- "HAIBUN_O_HTTPEXECUTORSTEPPER_LISTEN_PORT": "8125",
142
- "HAIBUN_O_HTTPEXECUTORSTEPPER_ACCESS_TOKEN": "some-great-password",
143
- "HAIBUN_O_WEBPLAYWRIGHT_STORAGE": "StorageMem"
144
- },
145
- "dev": {
146
- "watch": "modules/**/build/**/*.js",
147
- "debug": {
148
- "type": "node"
149
- }
150
- },
151
- },
152
- ```
153
-
154
- ### Server Tools
155
- Depending on which Haibun modules you have configured, you might see tools like:
156
-
157
- - `VariablesStepper-set` - Set variable values
158
- - `VariablesStepper-display` - Display variable values
159
- - `WebPlaywright-gotoPage` - Navigate to web pages
160
- - `Haibun-comment` - Add comments
161
- - Any locally configured steppers
162
-
163
- ### Client Tools
164
- - `list mcp tools` - Discover tools available from external MCP servers
87
+ | Environment Variable | Description |
88
+ |---------------------|-------------|
89
+ | `HAIBUN_O_HTTPEXECUTORSTEPPER_LISTEN_PORT` | HTTP API port (e.g., 8125) |
90
+ | `HAIBUN_O_HTTPEXECUTORSTEPPER_ACCESS_TOKEN` | HTTP API auth token |
91
+ | `HAIBUN_O_MCPSERVERSTEPPER_REMOTE_PORT` | Connect to remote HTTP executor |
92
+ | `HAIBUN_O_MCPSERVERSTEPPER_ACCESS_TOKEN` | Remote executor auth token |
93
+ | `HAIBUN_O_WEBPLAYWRIGHT_STORAGE` | Storage backend (StorageMem) |
@@ -0,0 +1,19 @@
1
+ /**
2
+ * HttpPrompterClient - HTTP client for accessing remote prompter service endpoints.
3
+ * Used by MCP server tools to retrieve and respond to prompts via HTTP API.
4
+ */
5
+ export declare class HttpPrompterClient {
6
+ private httpBaseUrl;
7
+ private accessToken?;
8
+ constructor(httpBaseUrl: string, accessToken?: string);
9
+ private getHeaders;
10
+ /**
11
+ * Get all pending prompts by calling the HTTP prompter endpoint
12
+ */
13
+ getPrompts(): Promise<any>;
14
+ /**
15
+ * Respond to a prompt by calling the HTTP prompter endpoint
16
+ */
17
+ respondToPrompt(id: string, response: string): Promise<any>;
18
+ }
19
+ //# sourceMappingURL=http-prompter-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-prompter-client.d.ts","sourceRoot":"","sources":["../../src/lib/http-prompter-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,kBAAkB;IAElB,OAAO,CAAC,WAAW;IAAU,OAAO,CAAC,WAAW,CAAC;gBAAzC,WAAW,EAAE,MAAM,EAAU,WAAW,CAAC,EAAE,MAAM;IAIrE,OAAO,CAAC,UAAU;IAYlB;;OAEG;IACG,UAAU;IAsBhB;;OAEG;IACG,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAkBlD"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * HttpPrompterClient - HTTP client for accessing remote prompter service endpoints.
3
+ * Used by MCP server tools to retrieve and respond to prompts via HTTP API.
4
+ */
5
+ export class HttpPrompterClient {
6
+ httpBaseUrl;
7
+ accessToken;
8
+ constructor(httpBaseUrl, accessToken) {
9
+ this.httpBaseUrl = httpBaseUrl;
10
+ this.accessToken = accessToken;
11
+ this.httpBaseUrl = httpBaseUrl;
12
+ }
13
+ getHeaders() {
14
+ const headers = {
15
+ 'Content-Type': 'application/json'
16
+ };
17
+ if (this.accessToken) {
18
+ headers['Authorization'] = `Bearer ${this.accessToken}`;
19
+ }
20
+ return headers;
21
+ }
22
+ /**
23
+ * Get all pending prompts by calling the HTTP prompter endpoint
24
+ */
25
+ async getPrompts() {
26
+ const response = await fetch(`${this.httpBaseUrl}/prompts`, {
27
+ headers: this.getHeaders()
28
+ });
29
+ if (!response.ok) {
30
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
31
+ }
32
+ const responseData = await response.json();
33
+ // Handle different response formats:
34
+ // 1. Direct array: [prompt1, prompt2, ...]
35
+ // 2. Wrapped object: { prompts: [prompt1, prompt2, ...] }
36
+ if (Array.isArray(responseData)) {
37
+ return responseData;
38
+ }
39
+ else if (responseData && Array.isArray(responseData.prompts)) {
40
+ return responseData.prompts;
41
+ }
42
+ else {
43
+ // Return empty array for unexpected formats
44
+ return [];
45
+ }
46
+ }
47
+ /**
48
+ * Respond to a prompt by calling the HTTP prompter endpoint
49
+ */
50
+ async respondToPrompt(id, response) {
51
+ try {
52
+ const httpResponse = await fetch(`${this.httpBaseUrl}/prompts/${id}/respond`, {
53
+ method: 'POST',
54
+ headers: this.getHeaders(),
55
+ body: JSON.stringify({ response }),
56
+ });
57
+ if (!httpResponse.ok) {
58
+ throw new Error(`HTTP ${httpResponse.status}: ${httpResponse.statusText}`);
59
+ }
60
+ return await httpResponse.json();
61
+ }
62
+ catch (error) {
63
+ console.warn('Failed to respond to prompt via HTTP prompter:', error);
64
+ throw error;
65
+ }
66
+ }
67
+ }
68
+ //# sourceMappingURL=http-prompter-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-prompter-client.js","sourceRoot":"","sources":["../../src/lib/http-prompter-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IAEV;IAA6B;IAAjD,YAAoB,WAAmB,EAAU,WAAoB;QAAjD,gBAAW,GAAX,WAAW,CAAQ;QAAU,gBAAW,GAAX,WAAW,CAAS;QACpE,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IAChC,CAAC;IAEO,UAAU;QACjB,MAAM,OAAO,GAA2B;YACvC,cAAc,EAAE,kBAAkB;SAClC,CAAC;Q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EH,IAAI,CAAC,YAAY,CAAC,EAAE,EAAE,CAAC;gBACtB,MAAM,IAAI,KAAK,CAAC,QAAQ,YAAY,CAAC,MAAM,KAAK,YAAY,CAAC,UAAU,EAAE,CAAC,CAAC;YAC5E,CAAC;YAED,OAAO,MAAM,YAAY,CAAC,IAAI,EAAE,CAAC;QAClC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,CAAC,IAAI,CAAC,gDAAgD,EAAE,KAAK,CAAC,CAAC;YACtE,MAAM,KAAK,CAAC;QACb,CAAC;IACF,CAAC;CACD"}
@@ -1,20 +1,28 @@
1
1
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
  import { AStepper } from "@haibun/core/lib/astepper.js";
3
3
  import { TWorld } from "@haibun/core/lib/defs.js";
4
- interface RemoteExecutorConfig {
4
+ import { HttpPrompterClient } from './http-prompter-client.js';
5
+ type IRemoteExecutorConfig = {
5
6
  url: string;
6
7
  accessToken?: string;
7
- }
8
+ };
8
9
  export declare class MCPExecutorServer {
9
10
  private steppers;
10
11
  private world;
11
12
  private remoteConfig?;
12
13
  server: McpServer;
13
- constructor(steppers: AStepper[], world: TWorld, remoteConfig?: RemoteExecutorConfig);
14
+ httpPrompterClient?: HttpPrompterClient;
15
+ private samplingInterval?;
16
+ private _isRunning;
17
+ get isRunning(): boolean;
18
+ constructor(steppers: AStepper[], world: TWorld, remoteConfig?: IRemoteExecutorConfig);
14
19
  start(): Promise<void>;
15
20
  registerSteppers(): void;
21
+ registerPromptTools(): void;
16
22
  private createToolHandler;
17
23
  private executeViaRemoteApi;
24
+ startPromptSampling(): void;
25
+ stopPromptSampling(): void;
18
26
  }
19
27
  export {};
20
28
  //# sourceMappingURL=mcp-executor-server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-executor-server.d.ts","sourceRoot":"","sources":["../../src/lib/mcp-executor-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAy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AE,EAAU,KAAK,EAAE,MAAM,EAAU,YAAY,CAAC,EAAE,qBAAqB;IASvG,KAAK;IAgCX,gBAAgB;IA+BhB,mBAAmB;IAsFnB,OAAO,CAAC,iBAAiB;YAoDX,mBAAmB;IAgDjC,mBAAmB;IAInB,kBAAkB;CAGlB"}
@@ -5,26 +5,56 @@ import { namedInterpolation } from "@haibun/core/lib/namedVars.js";
5
5
  import { currentVersion as version } from '@haibun/core/currentVersion.js';
6
6
  import { constructorName } from "@haibun/core/lib/util/index.js";
7
7
  import { resolveAndExecuteStatement } from "@haibun/core/lib/util/resolveAndExecuteStatement.js";
8
+ import { HttpPrompterClient } from './http-prompter-client.js';
8
9
  export class MCPExecutorServer {
9
10
  steppers;
10
11
  world;
11
12
  remoteConfig;
12
13
  server;
14
+ httpPrompterClient;
15
+ samplingInterval;
16
+ _isRunning = false;
17
+ get isRunning() {
18
+ return this._isRunning;
19
+ }
13
20
  constructor(steppers, world, remoteConfig) {
14
21
  this.steppers = steppers;
15
22
  this.world = world;
16
23
  this.remoteConfig = remoteConfig;
24
+ // Log the execution mode
25
+ if (remoteConfig) {
26
+ this.world.logger.log(`🔗 MCPExecutorServer: Remote execution mode - connecting to ${remoteConfig.url}`);
27
+ }
28
+ else {
29
+ this.world.logger.log(`🏠 MCPExecutorServer: Local execution mode`);
30
+ }
17
31
  }
18
32
  async start() {
33
+ this._isRunning = true;
19
34
  this.server = new McpServer({
20
35
  name: "haibun-mcp",
21
36
  version,
22
37
  capabilities: {
23
38
  resources: {},
24
39
  tools: {},
40
+ sampling: {
41
+ enabled: true
42
+ }
25
43
  },
26
44
  });
45
+ // Initialize HTTP prompter client for debug prompt access
46
+ if (!this.remoteConfig?.url) {
47
+ this.world.logger.warn(`⚠️ MCPExecutorServer: No remote config URL provided - debug prompt tools will not be available`);
48
+ this.httpPrompterClient = undefined;
49
+ }
50
+ else {
51
+ this.httpPrompterClient = new HttpPrompterClient(this.remoteConfig.url, this.remoteConfig.accessToken);
52
+ this.world.logger.log(`🤖 MCPExecutorServer: HTTP prompter client initialized for debugging with URL ${this.remoteConfig.url}`);
53
+ // Prompt notifications now handled by MCPClientPrompter - no sampling needed
54
+ this.startPromptSampling();
55
+ }
27
56
  this.registerSteppers();
57
+ this.registerPromptTools();
28
58
  const transport = new StdioServerTransport();
29
59
  await this.server.connect(transport);
30
60
  }
@@ -53,11 +83,99 @@ export class MCPExecutorServer {
53
83
  }
54
84
  }
55
85
  }
86
+ registerPromptTools() {
87
+ // Tool to list pending debug prompts
88
+ this.server.registerTool('listDebugPrompts', {
89
+ description: 'List all pending debug prompts',
90
+ title: 'List Debug Prompts'
91
+ }, async () => {
92
+ if (!this.httpPrompterClient) {
93
+ return {
94
+ content: [{
95
+ type: "text",
96
+ text: JSON.stringify({
97
+ success: false,
98
+ error: 'HttpPrompterClient not initialized - no remote config URL provided',
99
+ prompts: [],
100
+ count: 0
101
+ }, null, 2)
102
+ }]
103
+ };
104
+ }
105
+ const prompts = await this.httpPrompterClient.getPrompts();
106
+ return {
107
+ content: [{
108
+ type: "text",
109
+ text: JSON.stringify({
110
+ prompts,
111
+ count: prompts.length,
112
+ message: prompts.length > 0 ?
113
+ `Found ${prompts.length} pending debug prompt(s)` :
114
+ 'No pending debug prompts'
115
+ }, null, 2)
116
+ }]
117
+ };
118
+ });
119
+ // Tool to respond to debug prompts
120
+ this.server.registerTool('respondToDebugPrompt', {
121
+ description: 'Respond to a debug prompt to continue execution',
122
+ title: 'Respond to Debug Prompt',
123
+ inputSchema: {
124
+ promptId: z.string(),
125
+ response: z.string()
126
+ }
127
+ }, async (input) => {
128
+ if (!this.httpPrompterClient) {
129
+ return {
130
+ content: [{
131
+ type: "text",
132
+ text: JSON.stringify({
133
+ success: false,
134
+ error: 'HttpPrompterClient not initialized - no remote config URL provided',
135
+ promptId: input.promptId
136
+ }, null, 2)
137
+ }]
138
+ };
139
+ }
140
+ try {
141
+ const result = await this.httpPrompterClient.respondToPrompt(input.promptId, input.response);
142
+ return {
143
+ content: [{
144
+ type: "text",
145
+ text: JSON.stringify({
146
+ success: true,
147
+ promptId: input.promptId,
148
+ response: input.response,
149
+ result,
150
+ message: `Debug prompt ${input.promptId} resolved with: "${input.response}"`
151
+ }, null, 2)
152
+ }]
153
+ };
154
+ }
155
+ catch (error) {
156
+ const errorMessage = error instanceof Error ? error.message : String(error);
157
+ return {
158
+ content: [{
159
+ type: "text",
160
+ text: JSON.stringify({
161
+ success: false,
162
+ error: errorMessage,
163
+ promptId: input.promptId
164
+ }, null, 2)
165
+ }]
166
+ };
167
+ }
168
+ });
169
+ }
56
170
  createToolHandler(stepperName, stepName, stepDef) {
57
171
  return async (input) => {
58
172
  try {
59
173
  let statement = stepDef.gwta || stepDef.exact || stepDef.match?.toString();
60
174
  if (stepDef.gwta && Object.keys(input).length > 0) {
175
+ // First, handle optional parts like ( empty)?
176
+ // Remove optional parts that are not used (for now, just remove all optional parts)
177
+ statement = statement.replace(/\([^)]*\)\?/g, '');
178
+ // Then replace the named variables
61
179
  for (const [key, value] of Object.entries(input)) {
62
180
  const pattern = new RegExp(`\\{${key}(:[^}]*)?\\}`, 'g');
63
181
  statement = statement.replace(pattern, String(value));
@@ -102,6 +220,10 @@ export class MCPExecutorServer {
102
220
  };
103
221
  if (this.remoteConfig.accessToken) {
104
222
  headers.Authorization = `Bearer ${this.remoteConfig.accessToken}`;
223
+ this.world.logger.log(`🔐 MCPExecutorServer: Using access token for authentication`);
224
+ }
225
+ else {
226
+ this.world.logger.warn(`⚠️ MCPExecutorServer: No access token available for remote API call`);
105
227
  }
106
228
  const maxRetries = 3;
107
229
  const retryDelay = 1000;
@@ -125,10 +247,19 @@ export class MCPExecutorServer {
125
247
  throw new Error(`Remote execution failed after ${maxRetries} attempts: ${errorMessage}`);
126
248
  }
127
249
  // Log retry attempt and wait before retrying
128
- console.warn(`Remote execution attempt ${attempt} failed: ${errorMessage}. Retrying in ${retryDelay}ms...`);
250
+ this.world.logger.warn(`Remote execution attempt ${attempt} failed: ${errorMessage}. Retrying in ${retryDelay}ms...`);
129
251
  await new Promise(resolve => setTimeout(resolve, retryDelay));
130
252
  }
131
253
  }
132
254
  }
255
+ // REMOVED: Redundant prompt sampling system
256
+ // Prompt notifications are now handled by MCPClientPrompter's showPrompt/hidePrompt methods
257
+ // This provides real-time notifications without polling overhead
258
+ startPromptSampling() {
259
+ this.world.logger.log('📡 MCP: Prompt notifications handled by MCPClientPrompter - no polling needed');
260
+ }
261
+ stopPromptSampling() {
262
+ this.world.logger.log('📡 MCP: No prompt sampling to stop - using real-time notifications');
263
+ }
133
264
  }
134
265
  //# sourceMappingURL=mcp-executor-server.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-executor-server.js","sourceRoot":"","sources":["../../src/lib/mcp-executor-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,CAAC,EAAe,MAAM,KAAK,CAAC;AAIrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,cAAc,IAAI,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAE3E,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,0BAA0B,EAAE,MAAM,qDAAqD,CAAC;AASjG,MAAM,OAAO,iBAAiB;IAET;IAA8B;IAAuB;IADzE,MAAM,CAAY;IAClB,YAAoB,QAAoB,EAAU,KAAa,EAAU,YAAmC;QAAxF,aAAQ,GAAR,QAAQ,CAAY;QAAU,UAAK,GAAL,KAAK,CAAQ;QAAU,iBAAY,GAAZ,YAAY,CAAuB;IAAI,CAAC;IAEjH,KAAK,CAAC,KAAK;QACV,IAAI,CAAC,MAAM,GAAG,IAAI,SAAS,CAAC;YAC3B,IAAI,EAAE,YAAY;YAClB,OAAO;YACP,YAAY,EAAE;gBACb,SAAS,EAAE,EAAE;gBACb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CAAC;gBAC7E,CAAC;gBAED,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;gBAC3C,OAAO,YAAY,CAAC;YAErB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBAE5E,IAAI,OAAO,KAAK,UAAU,EAAE,CAAC;oBAC5B,MAAM,IAAI,KAAK,CAAC,iCAAiC,UAAU,cAAc,YAAY,EAAE,CAAC,CAAC;gBAC1F,CAAC;gBAED,6CAA6C;gBAC7C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,4BAA4B,OAAO,YAAY,YAAY,iBAAiB,UAAU,OAAO,CAAC,CAAC;gBACtH,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;YAC/D,CAAC;QACF,CAAC;IACF,CAAC;IAED,4CAA4C;IAC5C,4FAA4F;IAC5F,iEAAiE;IACjE,mBAAmB;QAClB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,+EAA+E,CAAC,CAAC;IACxG,CAAC;IAED,kBAAkB;QACjB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,oEAAoE,CAAC,CAAC;IAC7F,CAAC;CACD"}
@@ -2,18 +2,18 @@ import { StdioServerParameters } from '@modelcontextprotocol/sdk/client/stdio.js
2
2
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
3
3
  import { BasePromptManager } from '@haibun/core/lib/base-prompt-manager.js';
4
4
  import { AStepper, IHasCycles, IHasOptions } from '@haibun/core/lib/astepper.js';
5
- import { TWorld, TNamed, TFeatureStep, IStepperCycles } from '@haibun/core/lib/defs.js';
5
+ import { TWorld, TNamed, IStepperCycles } from '@haibun/core/lib/defs.js';
6
6
  import { TPrompt, TPromptResponse } from '@haibun/core/lib/prompter.js';
7
7
  declare class MCPClientPrompter extends BasePromptManager {
8
- private serverParameters;
9
- private client?;
10
- private isConnected;
11
- constructor(serverParameters: StdioServerParameters);
8
+ private getClient;
9
+ private getConnectionStatus;
10
+ constructor(getClient: () => Client | undefined, getConnectionStatus: () => boolean);
12
11
  protected showPrompt(prompt: TPrompt): void;
13
12
  protected hidePrompt(id: string): void;
14
- private ensureConnection;
15
13
  prompt(prompt: TPrompt): Promise<TPromptResponse>;
16
14
  close(): Promise<void>;
15
+ notifyPromptShown(prompt: TPrompt): void;
16
+ notifyPromptHidden(id: string): void;
17
17
  }
18
18
  declare class MCPClientStepper extends AStepper implements IHasOptions, IHasCycles {
19
19
  static SERVER: string;
@@ -58,26 +58,37 @@ declare class MCPClientStepper extends AStepper implements IHasOptions, IHasCycl
58
58
  mcpPrompter?: MCPClientPrompter;
59
59
  setWorld(world: TWorld, steppers: AStepper[]): Promise<void>;
60
60
  private ensureConnection;
61
+ getClient(): Promise<Client | undefined>;
62
+ private fetchDebugPrompts;
63
+ private checkAndNotifyExistingPrompts;
61
64
  steps: {
62
- registerMcpPrompter: {
65
+ checkAndNotifyExistingPrompts: {
63
66
  gwta: string;
64
- action: (named: TNamed, featureStep: TFeatureStep) => Promise<import("@haibun/core/lib/defs.js").TOKActionResult | import("@haibun/core/lib/defs.js").TNotOKActionResult>;
67
+ action: () => Promise<import("@haibun/core/lib/defs.js").TOKActionResult | import("@haibun/core/lib/defs.js").TNotOKActionResult>;
65
68
  };
66
- unregisterMcpPrompter: {
69
+ testRealTimeNotifications: {
67
70
  gwta: string;
68
- action: (named: TNamed, featureStep: TFeatureStep) => Promise<import("@haibun/core/lib/defs.js").TOKActionResult | import("@haibun/core/lib/defs.js").TNotOKActionResult>;
71
+ action: () => Promise<import("@haibun/core/lib/defs.js").TOKActionResult | import("@haibun/core/lib/defs.js").TNotOKActionResult>;
69
72
  };
70
73
  listMcpTools: {
71
74
  gwta: string;
72
- action: (named: TNamed, featureStep: TFeatureStep) => Promise<import("@haibun/core/lib/defs.js").TOKActionResult | import("@haibun/core/lib/defs.js").TNotOKActionResult>;
75
+ action: () => Promise<import("@haibun/core/lib/defs.js").TOKActionResult | import("@haibun/core/lib/defs.js").TNotOKActionResult>;
76
+ };
77
+ listDebugPrompts: {
78
+ gwta: string;
79
+ action: () => Promise<import("@haibun/core/lib/defs.js").TOKActionResult | import("@haibun/core/lib/defs.js").TNotOKActionResult>;
80
+ };
81
+ respondToDebugPrompt: {
82
+ gwta: string;
83
+ action: ({ promptId, response }: TNamed) => Promise<import("@haibun/core/lib/defs.js").TOKActionResult | import("@haibun/core/lib/defs.js").TNotOKActionResult>;
73
84
  };
74
85
  promptViaMcp: {
75
86
  gwta: string;
76
- action: ({ message, options }: TNamed, featureStep: TFeatureStep) => Promise<import("@haibun/core/lib/defs.js").TOKActionResult | import("@haibun/core/lib/defs.js").TNotOKActionResult>;
87
+ action: ({ message, options }: TNamed) => Promise<import("@haibun/core/lib/defs.js").TOKActionResult | import("@haibun/core/lib/defs.js").TNotOKActionResult>;
77
88
  };
78
89
  promptViaMcpWithContext: {
79
90
  gwta: string;
80
- action: ({ message, context, options }: TNamed, featureStep: TFeatureStep) => Promise<import("@haibun/core/lib/defs.js").TOKActionResult | import("@haibun/core/lib/defs.js").TNotOKActionResult>;
91
+ action: ({ message, context, options }: TNamed) => Promise<import("@haibun/core/lib/defs.js").TOKActionResult | import("@haibun/core/lib/defs.js").TNotOKActionResult>;
81
92
  };
82
93
  };
83
94
  }