@mctx-ai/mcp-dev 1.0.4 → 1.0.5
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/package.json +1 -1
- package/src/server.js +14 -13
package/package.json
CHANGED
package/src/server.js
CHANGED
|
@@ -117,20 +117,21 @@ function formatError(error, rpcRequest) {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
/**
|
|
120
|
-
* Create Request
|
|
121
|
-
*
|
|
122
|
-
*
|
|
120
|
+
* Create a Web API Request for the app's fetch handler.
|
|
121
|
+
*
|
|
122
|
+
* The app's fetch handler (packages/server/src/server.js) uses the standard
|
|
123
|
+
* Web API Request interface: request.headers.get() and request.text(). A plain
|
|
124
|
+
* object does not satisfy that contract, so we construct a real Request using
|
|
125
|
+
* globalThis.Request, which is guaranteed in Node >=18 (project requires >=22).
|
|
126
|
+
*
|
|
127
|
+
* @param {string} rawBody - The raw JSON string already read from the Node IncomingMessage
|
|
123
128
|
*/
|
|
124
|
-
function createRequest(
|
|
125
|
-
return {
|
|
129
|
+
function createRequest(rawBody) {
|
|
130
|
+
return new globalThis.Request("http://localhost/", {
|
|
126
131
|
method: "POST",
|
|
127
|
-
headers:
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
async json() {
|
|
131
|
-
return body;
|
|
132
|
-
},
|
|
133
|
-
};
|
|
132
|
+
headers: { "Content-Type": "application/json" },
|
|
133
|
+
body: rawBody,
|
|
134
|
+
});
|
|
134
135
|
}
|
|
135
136
|
|
|
136
137
|
/**
|
|
@@ -386,7 +387,7 @@ export async function startDevServer(entryUrl, port) {
|
|
|
386
387
|
try {
|
|
387
388
|
// Delegate all requests to app's fetch handler (including initialize)
|
|
388
389
|
// The core SDK now handles initialize, initialized, and ping
|
|
389
|
-
const request = createRequest(
|
|
390
|
+
const request = createRequest(body);
|
|
390
391
|
const response = await app.fetch(request, {}, {});
|
|
391
392
|
|
|
392
393
|
const elapsed = Date.now() - startTime;
|