@mcp-consultant-tools/powerplatform 21.0.0-beta.1 → 23.0.0-beta.1
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 @@
|
|
|
1
|
+
{"version":3,"file":"http-server.d.ts","sourceRoot":"","sources":["../src/http-server.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* HTTP Server entry point for PowerPlatform MCP
|
|
4
|
+
* Enables use with ChatGPT via ngrok/tunnel
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* npm run start:http
|
|
8
|
+
* # Then: ngrok http 3000
|
|
9
|
+
*/
|
|
10
|
+
import express from 'express';
|
|
11
|
+
import { randomUUID } from 'crypto';
|
|
12
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
13
|
+
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
14
|
+
import { createEnvLoader } from '@mcp-consultant-tools/core';
|
|
15
|
+
import { registerPowerPlatformTools } from './index.js';
|
|
16
|
+
// Load environment variables (suppresses stdout for MCP protocol)
|
|
17
|
+
createEnvLoader();
|
|
18
|
+
const app = express();
|
|
19
|
+
app.use(express.json());
|
|
20
|
+
// CORS for ChatGPT compatibility
|
|
21
|
+
app.use((req, res, next) => {
|
|
22
|
+
res.header('Access-Control-Allow-Origin', '*');
|
|
23
|
+
res.header('Access-Control-Allow-Methods', 'GET, POST, DELETE, OPTIONS');
|
|
24
|
+
res.header('Access-Control-Allow-Headers', '*');
|
|
25
|
+
if (req.method === 'OPTIONS') {
|
|
26
|
+
return res.sendStatus(200);
|
|
27
|
+
}
|
|
28
|
+
next();
|
|
29
|
+
});
|
|
30
|
+
// Store transports by session ID for stateful mode
|
|
31
|
+
const transports = new Map();
|
|
32
|
+
// MCP endpoint - handles all HTTP methods
|
|
33
|
+
app.all('/mcp', async (req, res) => {
|
|
34
|
+
try {
|
|
35
|
+
// Check for existing session
|
|
36
|
+
const sessionId = req.headers['mcp-session-id'];
|
|
37
|
+
let transport;
|
|
38
|
+
if (sessionId && transports.has(sessionId)) {
|
|
39
|
+
// Reuse existing transport for this session
|
|
40
|
+
transport = transports.get(sessionId);
|
|
41
|
+
}
|
|
42
|
+
else if (req.method === 'GET' || (req.method === 'POST' && !sessionId)) {
|
|
43
|
+
// New session - create server and transport
|
|
44
|
+
const server = new McpServer({
|
|
45
|
+
name: 'powerplatform-http',
|
|
46
|
+
version: '21.0.0',
|
|
47
|
+
});
|
|
48
|
+
// Register all PowerPlatform tools and prompts
|
|
49
|
+
// (prompts are registered inside registerPowerPlatformTools)
|
|
50
|
+
registerPowerPlatformTools(server);
|
|
51
|
+
// Create transport with session management
|
|
52
|
+
transport = new StreamableHTTPServerTransport({
|
|
53
|
+
sessionIdGenerator: () => randomUUID(),
|
|
54
|
+
onsessioninitialized: (id) => {
|
|
55
|
+
transports.set(id, transport);
|
|
56
|
+
console.error(`Session initialized: ${id}`);
|
|
57
|
+
},
|
|
58
|
+
onsessionclosed: (id) => {
|
|
59
|
+
transports.delete(id);
|
|
60
|
+
console.error(`Session closed: ${id}`);
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
// Connect server to transport
|
|
64
|
+
await server.connect(transport);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
// Invalid request - session required but not found
|
|
68
|
+
res.status(400).json({ error: 'Invalid session' });
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
// Let transport handle the request
|
|
72
|
+
await transport.handleRequest(req, res);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
console.error('MCP HTTP error:', error);
|
|
76
|
+
if (!res.headersSent) {
|
|
77
|
+
res.status(500).json({ error: error.message });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
// Health check endpoint
|
|
82
|
+
app.get('/health', (req, res) => {
|
|
83
|
+
res.json({ status: 'ok', sessions: transports.size });
|
|
84
|
+
});
|
|
85
|
+
const PORT = process.env.HTTP_PORT || 3000;
|
|
86
|
+
app.listen(PORT, () => {
|
|
87
|
+
console.error(`PowerPlatform MCP HTTP server running on http://localhost:${PORT}/mcp`);
|
|
88
|
+
console.error(`Health check: http://localhost:${PORT}/health`);
|
|
89
|
+
console.error('');
|
|
90
|
+
console.error('To expose via ngrok: ngrok http ' + PORT);
|
|
91
|
+
});
|
|
92
|
+
//# sourceMappingURL=http-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-server.js","sourceRoot":"","sources":["../src/http-server.ts"],"names":[],"mappings":";AACA;;;;;;;GAOG;AACH,OAAO,OAA4C,MAAM,SAAS,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AACnG,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAExD,kEAAkE;AAClE,eAAe,EAAE,CAAC;AAElB,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC;AACtB,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;AAExB,iCAAiC;AACjC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAE,EAAE;IAC1D,GAAG,CAAC,MAAM,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAC;IAC/C,GAAG,CAAC,MAAM,CAAC,8BAA8B,EAAE,4BAA4B,CAAC,CAAC;IACzE,GAAG,CAAC,MAAM,CAAC,8BAA8B,EAAE,GAAG,CAAC,CAAC;IAChD,IAAI,GAAG,CAAC,MAAM,KAA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AC,kCAAkC,IAAI,SAAS,CAAC,CAAC;IAC/D,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAClB,OAAO,CAAC,KAAK,CAAC,kCAAkC,GAAG,IAAI,CAAC,CAAC;AAC3D,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-consultant-tools/powerplatform",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "23.0.0-beta.1",
|
|
4
4
|
"description": "MCP server for Microsoft PowerPlatform/Dataverse - read-only access (production-safe)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./build/index.js",
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"scripts": {
|
|
19
19
|
"build": "tsc",
|
|
20
20
|
"clean": "rm -rf build *.tsbuildinfo",
|
|
21
|
-
"prepublishOnly": "npm run build"
|
|
21
|
+
"prepublishOnly": "npm run build",
|
|
22
|
+
"start:http": "node build/http-server.js"
|
|
22
23
|
},
|
|
23
24
|
"keywords": [
|
|
24
25
|
"mcp",
|
|
@@ -43,13 +44,16 @@
|
|
|
43
44
|
"@mcp-consultant-tools/core": "^1.0.0",
|
|
44
45
|
"@modelcontextprotocol/sdk": "^1.0.4",
|
|
45
46
|
"axios": "^1.8.3",
|
|
47
|
+
"express": "^4.21.0",
|
|
46
48
|
"zod": "^3.24.1"
|
|
47
49
|
},
|
|
48
50
|
"devDependencies": {
|
|
51
|
+
"@types/express": "^4.17.21",
|
|
49
52
|
"@types/node": "^22.10.5",
|
|
50
53
|
"typescript": "^5.8.2"
|
|
51
54
|
},
|
|
52
55
|
"bin": {
|
|
53
|
-
"mcp-pp": "build/index.js"
|
|
56
|
+
"mcp-pp": "build/index.js",
|
|
57
|
+
"mcp-pp-http": "build/http-server.js"
|
|
54
58
|
}
|
|
55
59
|
}
|