@ratio-mcp/dev-server 1.0.0 → 1.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.
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +41 -9
- package/dist/index.js.map +1 -1
- package/dist/orchestrated-index.d.ts +16 -0
- package/dist/orchestrated-index.d.ts.map +1 -0
- package/dist/orchestrated-index.js +41 -0
- package/dist/orchestrated-index.js.map +1 -0
- package/dist/orchestrated-server.d.ts +16 -0
- package/dist/orchestrated-server.d.ts.map +1 -0
- package/dist/orchestrated-server.js +63 -0
- package/dist/orchestrated-server.js.map +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +26 -0
- package/dist/server.js.map +1 -1
- package/dist/services/orchestrator.d.ts +63 -0
- package/dist/services/orchestrator.d.ts.map +1 -0
- package/dist/services/orchestrator.js +769 -0
- package/dist/services/orchestrator.js.map +1 -0
- package/dist/services/response-formatter.d.ts +24 -0
- package/dist/services/response-formatter.d.ts.map +1 -0
- package/dist/services/response-formatter.js +311 -0
- package/dist/services/response-formatter.js.map +1 -0
- package/dist/services/session-state.d.ts +51 -0
- package/dist/services/session-state.d.ts.map +1 -0
- package/dist/services/session-state.js +248 -0
- package/dist/services/session-state.js.map +1 -0
- package/dist/services/tool-guard.d.ts +20 -0
- package/dist/services/tool-guard.d.ts.map +1 -0
- package/dist/services/tool-guard.js +164 -0
- package/dist/services/tool-guard.js.map +1 -0
- package/dist/store/requirements-store.d.ts.map +1 -1
- package/dist/store/requirements-store.js +16 -3
- package/dist/store/requirements-store.js.map +1 -1
- package/dist/store/token-store.d.ts.map +1 -1
- package/dist/store/token-store.js +8 -2
- package/dist/store/token-store.js.map +1 -1
- package/dist/templates/backend/.env.example +3 -1
- package/dist/tools/agent-chat.d.ts +9 -0
- package/dist/tools/agent-chat.d.ts.map +1 -0
- package/dist/tools/agent-chat.js +379 -0
- package/dist/tools/agent-chat.js.map +1 -0
- package/dist/tools/app-management.d.ts.map +1 -1
- package/dist/tools/app-management.js +29 -8
- package/dist/tools/app-management.js.map +1 -1
- package/dist/tools/auth.d.ts.map +1 -1
- package/dist/tools/auth.js +45 -8
- package/dist/tools/auth.js.map +1 -1
- package/dist/tools/build.d.ts.map +1 -1
- package/dist/tools/build.js +13 -2
- package/dist/tools/build.js.map +1 -1
- package/dist/tools/codegen.d.ts.map +1 -1
- package/dist/tools/codegen.js +39 -6
- package/dist/tools/codegen.js.map +1 -1
- package/dist/tools/gather-requirements.d.ts +3 -0
- package/dist/tools/gather-requirements.d.ts.map +1 -0
- package/dist/tools/gather-requirements.js +281 -0
- package/dist/tools/gather-requirements.js.map +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +7 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/lifecycle.d.ts.map +1 -1
- package/dist/tools/lifecycle.js +40 -32
- package/dist/tools/lifecycle.js.map +1 -1
- package/dist/tools/reference-data.d.ts +8 -0
- package/dist/tools/reference-data.d.ts.map +1 -0
- package/dist/tools/reference-data.js +79 -0
- package/dist/tools/reference-data.js.map +1 -0
- package/dist/tools/scaffold.d.ts.map +1 -1
- package/dist/tools/scaffold.js +17 -1
- package/dist/tools/scaffold.js.map +1 -1
- package/dist/tools/submission.d.ts.map +1 -1
- package/dist/tools/submission.js +79 -21
- package/dist/tools/submission.js.map +1 -1
- package/dist/tools/webhooks.d.ts +3 -0
- package/dist/tools/webhooks.d.ts.map +1 -0
- package/dist/tools/webhooks.js +303 -0
- package/dist/tools/webhooks.js.map +1 -0
- package/dist/utils/logger.d.ts +15 -5
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +93 -14
- package/dist/utils/logger.js.map +1 -1
- package/package.json +6 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Ratio Dev MCP Server — Entry Point
|
|
4
|
+
*
|
|
5
|
+
* This runs the ORCHESTRATED server by default, exposing a single `agent_chat`
|
|
6
|
+
* tool that manages the entire app development lifecycle via a state machine.
|
|
7
|
+
*
|
|
8
|
+
* To run the legacy server (24+ individual tools), use:
|
|
9
|
+
* RATIO_LEGACY_MODE=true node dist/index.js
|
|
10
|
+
*/
|
|
2
11
|
export {};
|
|
3
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;GAQG"}
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,48 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Ratio Dev MCP Server — Entry Point
|
|
4
|
+
*
|
|
5
|
+
* This runs the ORCHESTRATED server by default, exposing a single `agent_chat`
|
|
6
|
+
* tool that manages the entire app development lifecycle via a state machine.
|
|
7
|
+
*
|
|
8
|
+
* To run the legacy server (24+ individual tools), use:
|
|
9
|
+
* RATIO_LEGACY_MODE=true node dist/index.js
|
|
10
|
+
*/
|
|
11
|
+
// Load .env BEFORE any other imports so process.env is populated
|
|
12
|
+
// Must use dynamic imports to ensure dotenv runs before constants.ts is evaluated
|
|
13
|
+
import { config } from 'dotenv';
|
|
14
|
+
import { resolve, dirname } from 'path';
|
|
15
|
+
import { fileURLToPath } from 'url';
|
|
16
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
17
|
+
// __dirname = dist/ → go up to: dev-server/ → packages/ → ratio-mcp-v2/
|
|
18
|
+
const envPath = resolve(__dirname, '..', '..', '..', '.env');
|
|
19
|
+
config({ path: envPath });
|
|
5
20
|
async function main() {
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
await server.
|
|
10
|
-
|
|
21
|
+
// Dynamic imports — these run AFTER dotenv has loaded env vars
|
|
22
|
+
const { StdioServerTransport } = await import('@modelcontextprotocol/sdk/server/stdio.js');
|
|
23
|
+
const { createOrchestratedServer } = await import('./orchestrated-server.js');
|
|
24
|
+
const { createDevServer } = await import('./server.js');
|
|
25
|
+
const { logger } = await import('./utils/logger.js');
|
|
26
|
+
const legacyMode = process.env.RATIO_LEGACY_MODE === 'true';
|
|
27
|
+
logger.info(`Loaded .env from: ${envPath}`);
|
|
28
|
+
logger.info(`RATIO_API_BASE_URL = ${process.env.RATIO_API_BASE_URL || '(not set, using default)'}`);
|
|
29
|
+
if (legacyMode) {
|
|
30
|
+
logger.info('Starting Ratio Dev MCP Server (Legacy Mode — 24+ tools)...');
|
|
31
|
+
const server = createDevServer();
|
|
32
|
+
const transport = new StdioServerTransport();
|
|
33
|
+
await server.connect(transport);
|
|
34
|
+
logger.info('Ratio Dev MCP Server (Legacy) is running on stdio');
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
logger.info('Starting Ratio Dev MCP Server (Orchestrated — single agent_chat tool)...');
|
|
38
|
+
const server = createOrchestratedServer();
|
|
39
|
+
const transport = new StdioServerTransport();
|
|
40
|
+
await server.connect(transport);
|
|
41
|
+
logger.info('Ratio Dev MCP Server (Orchestrated) is running on stdio');
|
|
42
|
+
}
|
|
11
43
|
}
|
|
12
44
|
main().catch((error) => {
|
|
13
|
-
|
|
45
|
+
console.error('Fatal error:', error);
|
|
14
46
|
process.exit(1);
|
|
15
47
|
});
|
|
16
48
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","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C;QACjC,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;QAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAChC,MAAM,CAAC,IAAI,CAAC,mDAAmD,CAAC,CAAC;IACnE,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,IAAI,CAAC,0EAA0E,CAAC,CAAC;QACxF,MAAM,MAAM,GAAG,wBAAwB,EAAE,CAAC;QAC1C,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;QAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAChC,MAAM,CAAC,IAAI,CAAC,yDAAyD,CAAC,CAAC;IACzE,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Orchestrated Ratio Dev MCP Server — Entry Point
|
|
4
|
+
*
|
|
5
|
+
* This is the production entry point that exposes a SINGLE `agent_chat` tool
|
|
6
|
+
* instead of 24+ individual tools. The internal state machine ensures the
|
|
7
|
+
* correct tool is called at the right time in the right order.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* node dist/orchestrated-index.js
|
|
11
|
+
*
|
|
12
|
+
* Or via the bin alias:
|
|
13
|
+
* ratio-dev-orchestrated
|
|
14
|
+
*/
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=orchestrated-index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestrated-index.d.ts","sourceRoot":"","sources":["../src/orchestrated-index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;GAYG"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Orchestrated Ratio Dev MCP Server — Entry Point
|
|
4
|
+
*
|
|
5
|
+
* This is the production entry point that exposes a SINGLE `agent_chat` tool
|
|
6
|
+
* instead of 24+ individual tools. The internal state machine ensures the
|
|
7
|
+
* correct tool is called at the right time in the right order.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* node dist/orchestrated-index.js
|
|
11
|
+
*
|
|
12
|
+
* Or via the bin alias:
|
|
13
|
+
* ratio-dev-orchestrated
|
|
14
|
+
*/
|
|
15
|
+
// Load .env BEFORE any other imports so process.env is populated
|
|
16
|
+
// Must use dynamic imports to ensure dotenv runs before constants.ts is evaluated
|
|
17
|
+
import { config } from 'dotenv';
|
|
18
|
+
import { resolve, dirname } from 'path';
|
|
19
|
+
import { fileURLToPath } from 'url';
|
|
20
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
21
|
+
// __dirname = dist/ → go up to: dev-server/ → packages/ → ratio-mcp-v2/
|
|
22
|
+
const envPath = resolve(__dirname, '..', '..', '..', '.env');
|
|
23
|
+
config({ path: envPath });
|
|
24
|
+
async function main() {
|
|
25
|
+
// Dynamic imports — these run AFTER dotenv has loaded env vars
|
|
26
|
+
const { StdioServerTransport } = await import('@modelcontextprotocol/sdk/server/stdio.js');
|
|
27
|
+
const { createOrchestratedServer } = await import('./orchestrated-server.js');
|
|
28
|
+
const { logger } = await import('./utils/logger.js');
|
|
29
|
+
logger.info(`Loaded .env from: ${envPath}`);
|
|
30
|
+
logger.info(`RATIO_API_BASE_URL = ${process.env.RATIO_API_BASE_URL || '(not set, using default)'}`);
|
|
31
|
+
logger.info('Starting Ratio Dev MCP Server (Orchestrated Mode)...');
|
|
32
|
+
const server = createOrchestratedServer();
|
|
33
|
+
const transport = new StdioServerTransport();
|
|
34
|
+
await server.connect(transport);
|
|
35
|
+
logger.info('Ratio Dev MCP Server (Orchestrated) is running on stdio');
|
|
36
|
+
}
|
|
37
|
+
main().catch((error) => {
|
|
38
|
+
console.error('Fatal error:', error);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=orchestrated-index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestrated-index.js","sourceRoot":"","sources":["../src/orchestrated-index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;GAYG;AAEH,iEAAiE;AACjE,kFAAkF;AAClF,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC1D,wEAAwE;AACxE,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAC7D,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;AAE1B,KAAK,UAAU,IAAI;IACjB,+DAA+D;IAC/D,MAAM,EAAE,oBAAoB,EAAE,GAAG,MAAM,MAAM,CAAC,2CAA2C,CAAC,CAAC;IAC3F,MAAM,EAAE,wBAAwB,EAAE,GAAG,MAAM,MAAM,CAAC,0BAA0B,CAAC,CAAC;IAC9E,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAC;IAErD,MAAM,CAAC,IAAI,CAAC,qBAAqB,OAAO,EAAE,CAAC,CAAC;IAC5C,MAAM,CAAC,IAAI,CAAC,wBAAwB,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,0BAA0B,EAAE,CAAC,CAAC;IACpG,MAAM,CAAC,IAAI,CAAC,sDAAsD,CAAC,CAAC;IAEpE,MAAM,MAAM,GAAG,wBAAwB,EAAE,CAAC;IAC1C,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAE7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,MAAM,CAAC,IAAI,CAAC,yDAAyD,CAAC,CAAC;AACzE,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
/**
|
|
3
|
+
* Create the Orchestrated Ratio Dev MCP Server.
|
|
4
|
+
*
|
|
5
|
+
* Unlike the original server (which exposes 24+ individual tools),
|
|
6
|
+
* this server exposes a SINGLE `agent_chat` tool that orchestrates
|
|
7
|
+
* the entire app development lifecycle through a state machine.
|
|
8
|
+
*
|
|
9
|
+
* Benefits:
|
|
10
|
+
* - LLM doesn't need to decide tool ordering — the orchestrator handles it
|
|
11
|
+
* - Flow integrity is guaranteed — steps can't be skipped or called out of order
|
|
12
|
+
* - Simpler LLM integration — one tool to learn instead of 24
|
|
13
|
+
* - Production-grade reliability — deterministic state transitions
|
|
14
|
+
*/
|
|
15
|
+
export declare function createOrchestratedServer(): McpServer;
|
|
16
|
+
//# sourceMappingURL=orchestrated-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestrated-server.d.ts","sourceRoot":"","sources":["../src/orchestrated-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAMpE;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,IAAI,SAAS,CAsDpD"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { DEV_SERVER_NAME, DEV_SERVER_VERSION } from '@ratio-mcp/shared';
|
|
3
|
+
import { agentChatTool } from './tools/agent-chat.js';
|
|
4
|
+
import { logger } from './utils/logger.js';
|
|
5
|
+
/**
|
|
6
|
+
* Create the Orchestrated Ratio Dev MCP Server.
|
|
7
|
+
*
|
|
8
|
+
* Unlike the original server (which exposes 24+ individual tools),
|
|
9
|
+
* this server exposes a SINGLE `agent_chat` tool that orchestrates
|
|
10
|
+
* the entire app development lifecycle through a state machine.
|
|
11
|
+
*
|
|
12
|
+
* Benefits:
|
|
13
|
+
* - LLM doesn't need to decide tool ordering — the orchestrator handles it
|
|
14
|
+
* - Flow integrity is guaranteed — steps can't be skipped or called out of order
|
|
15
|
+
* - Simpler LLM integration — one tool to learn instead of 24
|
|
16
|
+
* - Production-grade reliability — deterministic state transitions
|
|
17
|
+
*/
|
|
18
|
+
export function createOrchestratedServer() {
|
|
19
|
+
const server = new McpServer({
|
|
20
|
+
name: `${DEV_SERVER_NAME}-orchestrated`,
|
|
21
|
+
version: DEV_SERVER_VERSION,
|
|
22
|
+
});
|
|
23
|
+
// Register the single unified tool
|
|
24
|
+
const shape = agentChatTool.inputSchema.shape;
|
|
25
|
+
server.tool(agentChatTool.name, agentChatTool.description, shape, async (args) => {
|
|
26
|
+
logger.toolCall(agentChatTool.name, args);
|
|
27
|
+
const startTime = Date.now();
|
|
28
|
+
try {
|
|
29
|
+
const result = await agentChatTool.handler(args);
|
|
30
|
+
const duration = Date.now() - startTime;
|
|
31
|
+
logger.toolResult(agentChatTool.name, duration, result);
|
|
32
|
+
return {
|
|
33
|
+
content: [
|
|
34
|
+
{
|
|
35
|
+
type: 'text',
|
|
36
|
+
text: JSON.stringify(result, null, 2),
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
const duration = Date.now() - startTime;
|
|
43
|
+
logger.toolError(agentChatTool.name, duration, error);
|
|
44
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
45
|
+
return {
|
|
46
|
+
content: [
|
|
47
|
+
{
|
|
48
|
+
type: 'text',
|
|
49
|
+
text: JSON.stringify({
|
|
50
|
+
error: true,
|
|
51
|
+
message,
|
|
52
|
+
tool: agentChatTool.name,
|
|
53
|
+
}, null, 2),
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
isError: true,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
logger.info(`${DEV_SERVER_NAME}-orchestrated initialized with single agent_chat tool`);
|
|
61
|
+
return server;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=orchestrated-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestrated-server.js","sourceRoot":"","sources":["../src/orchestrated-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,wBAAwB;IACtC,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;QAC3B,IAAI,EAAE,GAAG,eAAe,eAAe;QACvC,OAAO,EAAE,kBAAkB;KAC5B,CAAC,CAAC;IAEH,mCAAmC;IACnC,MAAM,KAAK,GAAI,aAAa,CAAC,WAA0C,CAAC,KAAK,CAAC;IAE9E,MAAM,CAAC,IAAI,CACT,aAAa,CAAC,IAAI,EAClB,aAAa,CAAC,WAAW,EACzB,KAAK,EACL,KAAK,EAAE,IAA6B,EAAE,EAAE;QACtC,MAAM,CA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AAC"}
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAQpE;;GAEG;AACH,wBAAgB,eAAe,IAAI,SAAS,CAsF3C"}
|
package/dist/server.js
CHANGED
|
@@ -2,6 +2,8 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
|
2
2
|
import { DEV_SERVER_NAME, DEV_SERVER_VERSION } from '@ratio-mcp/shared';
|
|
3
3
|
import { allDevTools } from './tools/index.js';
|
|
4
4
|
import { logger } from './utils/logger.js';
|
|
5
|
+
import { checkToolPrerequisites } from './services/tool-guard.js';
|
|
6
|
+
import { recordToolSuccess } from './services/session-state.js';
|
|
5
7
|
/**
|
|
6
8
|
* Create and configure the Ratio Dev MCP Server
|
|
7
9
|
*/
|
|
@@ -17,10 +19,34 @@ export function createDevServer() {
|
|
|
17
19
|
server.tool(tool.name, tool.description, shape, async (args) => {
|
|
18
20
|
logger.toolCall(tool.name, args);
|
|
19
21
|
const startTime = Date.now();
|
|
22
|
+
// ── Guard: check prerequisites before executing ──────────────
|
|
23
|
+
const guard = checkToolPrerequisites(tool.name);
|
|
24
|
+
if (!guard.allowed) {
|
|
25
|
+
const duration = Date.now() - startTime;
|
|
26
|
+
logger.info(`BLOCKED ${tool.name} (${duration}ms): ${guard.message}`);
|
|
27
|
+
return {
|
|
28
|
+
content: [
|
|
29
|
+
{
|
|
30
|
+
type: 'text',
|
|
31
|
+
text: JSON.stringify({
|
|
32
|
+
error: true,
|
|
33
|
+
blocked: true,
|
|
34
|
+
message: guard.message,
|
|
35
|
+
required_tools: guard.requiredTools,
|
|
36
|
+
tool: tool.name,
|
|
37
|
+
hint: `Please call ${guard.requiredTools?.join(' or ')} first, then retry ${tool.name}.`,
|
|
38
|
+
}, null, 2),
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
isError: true,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
20
44
|
try {
|
|
21
45
|
const result = await tool.handler(args);
|
|
22
46
|
const duration = Date.now() - startTime;
|
|
23
47
|
logger.toolResult(tool.name, duration, result);
|
|
48
|
+
// ── Record success in session state ────────────────────────
|
|
49
|
+
recordToolSuccess(tool.name, result);
|
|
24
50
|
return {
|
|
25
51
|
content: [
|
|
26
52
|
{
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;QAC3B,IAAI,EAAE,eAAe;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,WAAW,CAAC,MAAM,QAAQ,CAAC,CAAC;IAC/E,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase definitions in the Ratio app development lifecycle.
|
|
3
|
+
* Each phase represents a logical group of activities that must be completed in order.
|
|
4
|
+
*/
|
|
5
|
+
export type Phase = 'auth' | 'app_setup' | 'requirements' | 'webhooks' | 'frontend_build' | 'review_wait' | 'publish_oauth' | 'backend_codegen' | 'complete';
|
|
6
|
+
/**
|
|
7
|
+
* Result returned by the orchestrator showing exactly what to do next.
|
|
8
|
+
* The caller uses this to invoke the correct tool with the right arguments.
|
|
9
|
+
*/
|
|
10
|
+
export interface OrchestratorResult {
|
|
11
|
+
phase: Phase;
|
|
12
|
+
step: string;
|
|
13
|
+
toolToCall: string;
|
|
14
|
+
toolArgs: Record<string, unknown>;
|
|
15
|
+
needsInput: boolean;
|
|
16
|
+
inputPrompt?: string;
|
|
17
|
+
inputFields?: string[];
|
|
18
|
+
message: string;
|
|
19
|
+
phase_description: string;
|
|
20
|
+
progress: {
|
|
21
|
+
current: number;
|
|
22
|
+
total: number;
|
|
23
|
+
percentage: number;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Main orchestrator function: determines the exact next step based on session state.
|
|
28
|
+
*
|
|
29
|
+
* @param userInput - Optional user input (credentials, selections, configuration details)
|
|
30
|
+
* @returns OrchestratorResult describing what to do next
|
|
31
|
+
*/
|
|
32
|
+
export declare function getNextStep(userInput?: Record<string, unknown>): OrchestratorResult;
|
|
33
|
+
/**
|
|
34
|
+
* Get the current phase without computing the next step details.
|
|
35
|
+
* Useful for status checks and phase-only queries.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getCurrentPhase(): Phase;
|
|
38
|
+
/**
|
|
39
|
+
* Get a human-friendly description of a phase.
|
|
40
|
+
*/
|
|
41
|
+
export declare function getPhaseDescription(phase: Phase): string;
|
|
42
|
+
/**
|
|
43
|
+
* Check if a phase can be skipped by the user.
|
|
44
|
+
* Currently only webhooks is optional.
|
|
45
|
+
*/
|
|
46
|
+
export declare function canSkipPhase(phase: Phase): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Get the total number of steps across all phases.
|
|
49
|
+
*/
|
|
50
|
+
export declare function getTotalSteps(): number;
|
|
51
|
+
/**
|
|
52
|
+
* Get metadata about a specific phase (description, step count, skippable).
|
|
53
|
+
*/
|
|
54
|
+
export declare function getPhaseMetadata(phase: Phase): {
|
|
55
|
+
description: string;
|
|
56
|
+
skippable: boolean;
|
|
57
|
+
stepCount: number;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Helper: Get all phases in order.
|
|
61
|
+
*/
|
|
62
|
+
export declare function getAllPhases(): Phase[];
|
|
63
|
+
//# sourceMappingURL=orchestrator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../src/services/orchestrator.ts"],"names":[],"mappings":"AAYA;;;GAGG;AACH,MAAM,MAAM,KAAK,GACb,MAAM,GACN,WAAW,GACX,cAAc,GACd,UAAU,GACV,gBAAgB,GAChB,aAAa,GACb,eAAe,GACf,iBAAiB,GACjB,UAAU,CAAC;AAEf;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IAEjC,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IAGb,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAGlC,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IAGvB,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE;QACR,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM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