-
Pre-submission Checklist
Question Category
Your QuestionThe document is very high level covering SDK usage mostly. But I want to know the low level stuff, how to implement a MCP server from scratch? In particular, I'm trying to turn a legacy c++ project to a MCP server. What I don't get is how a client knows the server port? this is not covered in the doc, and I checked the Python SDK's source, it uses 8000 as the default. But what if there are multiple servers, how can they resolve the port conflict and let the client know their ports? I don't see port configuration in the config json either. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
For your second question: Assuming you're talking about MCP servers using SSE transports, my understanding is that similar to other HTTP servers the server would handle conflicts by allowing for configurable ports, or some kind of dynamic assignment where they fall back to an alternative port that isn't in use. In other words, I think its up to the MCP server author to decide. The only way I'm aware of for the MCP client to know the expected port(s) to use is for the server to document this in advance, so the client knows how to configure the correct URL and port for that server, |
Beta Was this translation helpful? Give feedback.
-
It's entirely up to the MCP Client you're using. Check out the LibreChat project for some examples of how they are enabling MCP Clients & Servers to communicate effortlessly using an expressjs middleware. Hint: Strategy pattern FTW |
Beta Was this translation helpful? Give feedback.
-
I have investigated its source code, the port selection is controlled by the client using environment variable. setting FASTMCP_port=9090 will change the port to 9090 |
Beta Was this translation helpful? Give feedback.
I have investigated its source code, the port selection is controlled by the client using environment variable.
setting FASTMCP_port=9090 will change the port to 9090