@@ -32,24 +32,6 @@ interface Env {
3232}
3333
3434const app = new Hono < { Bindings : Env } > ( )
35- const mcpServerCache = new Map < string , ReturnType < typeof createMcpServer > > ( )
36-
37- function getMcpServer ( env : Env ) {
38- const allowlist = env . EXTERNAL_DOC_HOST_ALLOWLIST ?? ""
39- const blocklist = env . EXTERNAL_DOC_HOST_BLOCKLIST ?? ""
40- const cacheKey = `${ allowlist } \n---\n${ blocklist } `
41- const cached = mcpServerCache . get ( cacheKey )
42- if ( cached ) {
43- return cached
44- }
45-
46- const server = createMcpServer ( {
47- EXTERNAL_DOC_HOST_ALLOWLIST : env . EXTERNAL_DOC_HOST_ALLOWLIST ,
48- EXTERNAL_DOC_HOST_BLOCKLIST : env . EXTERNAL_DOC_HOST_BLOCKLIST ,
49- } )
50- mcpServerCache . set ( cacheKey , server )
51- return server
52- }
5335
5436app . use ( "*" , async ( c , next ) => {
5537 await next ( )
@@ -85,7 +67,10 @@ app.use("*", async (c, next) => {
8567} )
8668
8769app . all ( "/mcp" , async ( c ) => {
88- const mcpServer = getMcpServer ( c . env )
70+ const mcpServer = createMcpServer ( {
71+ EXTERNAL_DOC_HOST_ALLOWLIST : c . env . EXTERNAL_DOC_HOST_ALLOWLIST ,
72+ EXTERNAL_DOC_HOST_BLOCKLIST : c . env . EXTERNAL_DOC_HOST_BLOCKLIST ,
73+ } )
8974 const transport = new StreamableHTTPTransport ( )
9075 await mcpServer . connect ( transport )
9176 return transport . handleRequest ( c )
0 commit comments