@phidiassj/aiyoperps-mcp-bridge 0.8.2 → 0.8.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/README.md +2 -0
- package/bin/aiyoperps-mcp-bridge.js +27 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -49,12 +49,12 @@ async function bootstrap() {
|
|
|
49
49
|
function tryProcessBuffer() {
|
|
50
50
|
while (true) {
|
|
51
51
|
if (expectedBodyLength === null) {
|
|
52
|
-
const
|
|
53
|
-
if (
|
|
52
|
+
const headerInfo = findHeaderBoundary(buffer);
|
|
53
|
+
if (!headerInfo) {
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
const headerText = buffer.subarray(0,
|
|
57
|
+
const headerText = buffer.subarray(0, headerInfo.index).toString('utf8');
|
|
58
58
|
const lengthMatch = /content-length:\s*(\d+)/i.exec(headerText);
|
|
59
59
|
if (!lengthMatch) {
|
|
60
60
|
logError('[aiyoperps-mcp-bridge] invalid MCP frame: missing Content-Length');
|
|
@@ -62,7 +62,7 @@ function tryProcessBuffer() {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
expectedBodyLength = Number.parseInt(lengthMatch[1], 10);
|
|
65
|
-
buffer = buffer.subarray(
|
|
65
|
+
buffer = buffer.subarray(headerInfo.bodyOffset);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
if (buffer.length < expectedBodyLength) {
|
|
@@ -80,6 +80,27 @@ function tryProcessBuffer() {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
function findHeaderBoundary(sourceBuffer) {
|
|
84
|
+
const crlfIndex = sourceBuffer.indexOf('\r\n\r\n');
|
|
85
|
+
const lfIndex = sourceBuffer.indexOf('\n\n');
|
|
86
|
+
|
|
87
|
+
if (crlfIndex === -1 && lfIndex === -1) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (crlfIndex !== -1 && (lfIndex === -1 || crlfIndex <= lfIndex)) {
|
|
92
|
+
return {
|
|
93
|
+
index: crlfIndex,
|
|
94
|
+
bodyOffset: crlfIndex + 4
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
index: lfIndex,
|
|
100
|
+
bodyOffset: lfIndex + 2
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
83
104
|
async function handleMessage(bodyBuffer) {
|
|
84
105
|
const bodyText = bodyBuffer.toString('utf8');
|
|
85
106
|
let payload;
|
|
@@ -174,8 +195,9 @@ function writeFrame(jsonText) {
|
|
|
174
195
|
}
|
|
175
196
|
|
|
176
197
|
function parseOptions(args) {
|
|
198
|
+
const defaultUrl = env.AIYOPERPS_MCP_URL || 'http://127.0.0.1:5078/mcp';
|
|
177
199
|
const options = {
|
|
178
|
-
url:
|
|
200
|
+
url: defaultUrl,
|
|
179
201
|
healthCheck: false,
|
|
180
202
|
startupPing: false,
|
|
181
203
|
quiet: false,
|