Using MCP server with existing Tomcat hosted Java application #490
-
Pre-submission Checklist
Question Category
Your QuestionI have an existing Java application deployed on a Tomcat server, and I want to embed an MCP server into it using the official [MCP Java SDK] (https://github.com/modelcontextprotocol/java-sdk). The SDK provides APIs to create a server that supports multiple transport types, such as HttpServletStreamableServerTransportProvider. Each of these transport types is itself implemented as a servlet. Ideally, these transport types should be extensible so that I could subclass one of them within my application. However, the current SDK does not allow extending the transport classes. Is there an alternative approach to integrate an MCP server into an existing Tomcat-hosted Java application? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I'm also interested in understanding the decision to make that class private and non-extensible. I forked the project and changed the access modifiers to make the classes public and extensible. You could also replicate the transport class and implement it yourself. |
Beta Was this translation helpful? Give feedback.
You can implement a servlet that extends HTTPServlet and then in your class's service method delegate service call to one of the transport types available from MCP SDK.
Pseudocode -
class myServlet extends HTTPServlet {
private transient HttpServletStreamableServerTransportProvider transport;
}
}