@cyanheads/git-mcp-server
Version:
An MCP (Model Context Protocol) server enabling LLMs and AI agents to interact with Git repositories. Provides tools for comprehensive Git operations including clone, commit, branch, diff, log, status, push, pull, merge, rebase, worktree, tag management,
58 lines • 1.96 kB
JavaScript
/**
* @fileoverview Provides a bridge between the MCP SDK's Node.js-style
* streamable HTTP transport and Hono's Web Standards-based streaming response.
* @module src/mcp-server/transports/core/honoNodeBridge
*/
import { PassThrough } from "stream";
/**
* A mock ServerResponse that pipes writes to a PassThrough stream.
* This is the bridge between Model Context Protocol's SDK's Node.js-style response handling
* and Hono's stream-based body. It captures status and headers.
*/
export class HonoStreamResponse extends PassThrough {
statusCode = 200;
headers = {};
constructor() {
super();
}
writeHead(statusCode, headers) {
this.statusCode = statusCode;
if (headers) {
this.headers = { ...this.headers, ...headers };
}
return this;
}
setHeader(name, value) {
this.headers[name.toLowerCase()] = value;
return this;
}
getHeader(name) {
return this.headers[name.toLowerCase()];
}
getHeaders() {
return this.headers;
}
removeHeader(name) {
delete this.headers[name.toLowerCase()];
}
write(chunk, encodingOrCallback, callback) {
const encoding = typeof encodingOrCallback === "string" ? encodingOrCallback : undefined;
const cb = typeof encodingOrCallback === "function" ? encodingOrCallback : callback;
if (encoding) {
return super.write(chunk, encoding, cb);
}
return super.write(chunk, cb);
}
end(chunk, encodingOrCallback, callback) {
const encoding = typeof encodingOrCallback === "string" ? encodingOrCallback : undefined;
const cb = typeof encodingOrCallback === "function" ? encodingOrCallback : callback;
if (encoding) {
super.end(chunk, encoding, cb);
}
else {
super.end(chunk, cb);
}
return this;
}
}
//# sourceMappingURL=honoNodeBridge.js.map