@mctx-ai/mcp-dev 1.0.3 → 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/server.js +14 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mctx-ai/mcp-dev",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Local development server for @mctx-ai/mcp-server with hot reload",
5
5
  "type": "module",
6
6
  "main": "./src/cli.js",
package/src/server.js CHANGED
@@ -117,20 +117,21 @@ function formatError(error, rpcRequest) {
117
117
  }
118
118
 
119
119
  /**
120
- * Create Request-like object compatible with app's fetch handler.
121
- * headers must be a Headers instance (not a plain object) so that
122
- * request.headers.get(...) works in packages/server/src/server.js.
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(body) {
125
- return {
129
+ function createRequest(rawBody) {
130
+ return new globalThis.Request("http://localhost/", {
126
131
  method: "POST",
127
- headers: new Headers({
128
- "content-type": "application/json",
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(rpcRequest);
390
+ const request = createRequest(body);
390
391
  const response = await app.fetch(request, {}, {});
391
392
 
392
393
  const elapsed = Date.now() - startTime;