Skip to content

Commit 5f77ea5

Browse files
auto: format code
1 parent 33a7ff1 commit 5f77ea5

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

packages/opencontrol/src/index.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
import { type Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
2-
import { type JSONRPCMessage } from "@modelcontextprotocol/sdk/types.js";
3-
import { Hono } from "hono";
4-
import { HTTPException } from "hono/http-exception";
1+
import { type Transport } from "@modelcontextprotocol/sdk/shared/transport.js"
2+
import { type JSONRPCMessage } from "@modelcontextprotocol/sdk/types.js"
3+
import { Hono } from "hono"
4+
import { HTTPException } from "hono/http-exception"
55

66
class OpenControlTransport implements Transport {
77
constructor(private cb: (response: JSONRPCMessage) => void) {}
88
async start(): Promise<void> {}
99
async send(message: JSONRPCMessage): Promise<void> {
10-
this.cb(message);
10+
this.cb(message)
1111
}
1212
async close(): Promise<void> {}
13-
onclose?: (() => void) | undefined;
14-
onerror?: ((error: Error) => void) | undefined;
15-
onmessage?: ((message: JSONRPCMessage) => void) | undefined;
13+
onclose?: (() => void) | undefined
14+
onerror?: ((error: Error) => void) | undefined
15+
onmessage?: ((message: JSONRPCMessage) => void) | undefined
1616
}
1717

1818
export interface OpenControlOptions {
19-
key?: string;
19+
key?: string
2020
}
2121

2222
export function create(
@@ -26,24 +26,24 @@ export function create(
2626
return new Hono()
2727
.use((c, next) => {
2828
if (options?.key) {
29-
const authorization = c.req.header("Authorization");
29+
const authorization = c.req.header("Authorization")
3030
if (authorization !== `Bearer ${options?.key}`) {
31-
throw new HTTPException(401);
31+
throw new HTTPException(401)
3232
}
3333
}
34-
return next();
34+
return next()
3535
})
3636
.post("/mcp", async (c) => {
37-
const body = await c.req.json();
38-
console.log("<-", body);
37+
const body = await c.req.json()
38+
console.log("<-", body)
3939
const response = await new Promise<any>(async (resolve) => {
40-
const transport = new OpenControlTransport(resolve);
41-
console.log("connecting to transport");
42-
await server.connect(transport);
43-
console.log("connected to transport");
44-
transport.onmessage?.(body);
45-
});
46-
console.log("->", JSON.stringify(response, null, 2));
47-
return c.json(response);
48-
});
40+
const transport = new OpenControlTransport(resolve)
41+
console.log("connecting to transport")
42+
await server.connect(transport)
43+
console.log("connected to transport")
44+
transport.onmessage?.(body)
45+
})
46+
console.log("->", JSON.stringify(response, null, 2))
47+
return c.json(response)
48+
})
4949
}

0 commit comments

Comments
 (0)