@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 CHANGED
@@ -14,6 +14,8 @@ Custom endpoint:
14
14
  npx -y @phidiassj/aiyoperps-mcp-bridge --url http://127.0.0.1:5078/mcp
15
15
  ```
16
16
 
17
+ Use `--url` whenever your MCP endpoint is not the local default.
18
+
17
19
  Or via environment variable:
18
20
 
19
21
  ```bash
@@ -49,12 +49,12 @@ async function bootstrap() {
49
49
  function tryProcessBuffer() {
50
50
  while (true) {
51
51
  if (expectedBodyLength === null) {
52
- const headerEndIndex = buffer.indexOf('\r\n\r\n');
53
- if (headerEndIndex === -1) {
52
+ const headerInfo = findHeaderBoundary(buffer);
53
+ if (!headerInfo) {
54
54
  return;
55
55
  }
56
56
 
57
- const headerText = buffer.subarray(0, headerEndIndex).toString('utf8');
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(headerEndIndex + 4);
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: env.AIYOPERPS_MCP_URL || 'http://127.0.0.1:5078/mcp',
200
+ url: defaultUrl,
179
201
  healthCheck: false,
180
202
  startupPing: false,
181
203
  quiet: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phidiassj/aiyoperps-mcp-bridge",
3
- "version": "0.8.2",
3
+ "version": "0.8.5",
4
4
  "description": "Stdio MCP bridge for the AiyoPerps local HTTP MCP endpoint.",
5
5
  "license": "MIT",
6
6
  "bin": {