Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support SSE transport #14

Closed
alexanderjeurissen opened this issue Jan 30, 2025 · 2 comments · May be fixed by #15
Closed

Support SSE transport #14

alexanderjeurissen opened this issue Jan 30, 2025 · 2 comments · May be fixed by #15

Comments

@alexanderjeurissen
Copy link
Contributor

Currently the openapi-mcp-server only works over the STDIO transport.
This is great for applications like the claude desktop app, but limits it availability to MCP hosts that can't run subproceses.

For such cases SSE is a more popular transport (https://modelcontextprotocol.io/docs/concepts/transports#server-sent-events-sse)

Implementing SSE support is rather lightweight, and can be achieved with the existing SDK, and express.js

example (from https://github.com/modelcontextprotocol/servers/tree/main/src/everything):

import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
import express from "express";
import { createServer } from "./everything.js";

const app = express();

const { server, cleanup } = createServer();

let transport: SSEServerTransport;

app.get("/sse", async (req, res) => {
  console.log("Received connection");
  transport = new SSEServerTransport("/message", res);
  await server.connect(transport);

  server.onclose = async () => {
    await cleanup();
    await server.close();
    process.exit(0);
  };
});

app.post("/message", async (req, res) => {
  console.log("Received message");

  await transport.handlePostMessage(req, res);
});

const PORT = process.env.PORT || 3001;
app.listen(PORT, () => {
  console.log(`Server is running on port ${PORT}`);
});
alexanderjeurissen added a commit to alexanderjeurissen/openapi-mcp-server that referenced this issue Jan 30, 2025
Fixes janwilmake#14

Add support for SSE transport in the server.

* Import `SSEServerTransport` from `@modelcontextprotocol/sdk/server/sse.js` in `scripts/start-proxy.ts`.
* Add a new flag `--sse` to handle SSE transport connections in `scripts/start-proxy.ts`.
* Modify the `startProxy` function in `scripts/start-proxy.ts` to handle both STDIO and SSE transports.
* Update `MCPProxy` class in `src/mcp/proxy.ts` to make the `server` property public.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/snaggle-ai/openapi-mcp-server/issues/14?shareId=XXXX-XXXX-XXXX-XXXX).
@eastlondoner
Copy link

Thank you king! Will review this evening

@janwilmake
Copy link
Owner

Due to the fact that auth is hard to solve still with MCP, openapi-mcp 2.0 onwards does not include adding the openapi as tools. This MCP server is now mainly focused on making it easier to do codegen with complex apis as it can easily find the right endpoints and their spec.

However, it features getting easy navigation through huge OpenAPIs.

For adding support of openapis as tools, please open a discussion to discuss a better solution.

And thanks @eastlondoner for letting me do this!

I hope we can make this an amazing large OSS repo with many contributors, making AI tool use and API codegen truly open!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants