Sub topic 14
Sharing and deploying the server for your team
This chapter assumes you have a working server with typed tools, have tested it with the MCP Inspector, and know the difference between the stdio and Streamable HTTP transports. Here you decide how your teammates will get and run the server.
Two deployment models
There are two ways to share a server. Which one you choose follows from the transport.
- Local distribution (stdio). Each person installs the server and their host launches it as a subprocess. The server runs with that person's permissions and credentials.
- Remote hosting (Streamable HTTP). You run one server process that many hosts connect to over a URL. The server runs with its own service credentials.
Packaging for local use
Telling people to "copy server.py and install the right packages" breaks quickly. Package the server so one command installs it with its dependencies.
Add a pyproject.toml with a console script entry point:
[project]
name = "team-tools"
version = "0.1.0"
requires-python = ">=3.10"
dependencies = ["mcp[cli]"]
[project.scripts]
team-tools = "team_tools.server:main"
[build-system]
requires = ["setuptools>=68"]
build-backend = "setuptools.build_meta"In team_tools/server.py, wrap the run call in a main function so the entry point can call it:
def main() -> None:
mcp.run() # stdio transport by default
if __name__ == "__main__":
main()Publish the built package to your internal package index, or install it straight from your repository. Then each person's host configuration can use a stable command. With uvx, no manual install step is needed:
{
"mcpServers": {
"team-tools": {
"command": "uvx",
"args": ["--from", "git+https://git.example.com/platform/team-tools", "team-tools"]
}
}
}Pin a tag or commit in the URL so that everyone runs the same version, and so that a change on the main branch doesn't reach people's machines unreviewed.
Hosting a shared server
Choose remote hosting when the server needs credentials that individuals shouldn't hold, such as a deploy system's service account, or when you want updates to reach everyone at once.
With the Python SDK, switch the transport when you start the server:
def main() -> None:
mcp.run(transport="streamable-http") # serves at /mcp on port 8000 by defaultPackage this process as a container image and run it on your usual platform. Put it behind a reverse proxy or load balancer that terminates HTTPS. A minimal image looks like this:
FROM python:3.12-slim
WORKDIR /app
COPY . .
RUN pip install --no-cache-dir .
EXPOSE 8000
CMD ["team-tools"]Hosts then point at the URL instead of a command. The exact key names vary by host, so check your host's documentation.
What changes when the server is shared
A remote server is reachable by anyone who can reach the network address. Settle these before you announce it:
- Authentication. Never expose an unauthenticated server that can touch real systems. The MCP specification defines an OAuth-based authorization flow for HTTP transports. You can also place the server behind your existing identity-aware proxy.
- Per-user identity. If tools act on behalf of a person, pass their identity through and check it. Otherwise every caller gets the service account's full access.
- Origin and network limits. Restrict who can connect. Validate the
Originheader and don't bind a local-only server to all interfaces. - Logging. Record which user called which tool with which arguments, and keep secrets out of those logs.
- Versioning. Tool names and schemas are a contract with models and with people's saved workflows. Add new optional parameters rather than renaming or removing existing ones.
Choosing between the models
| Question | Local (stdio) | Remote (Streamable HTTP) |
|---|---|---|
| Whose credentials are used? | Each user's own | A service account, or the user's via authorization |
| How do updates reach users? | Users reinstall or re-resolve the pinned version | You redeploy once |
| Setup per person | Edit host config and install | Add a URL and sign in |
| Operations burden | None | You run, monitor, and secure a service |
Start local when the tools wrap each person's own CLI access. Move to remote when you need shared credentials, central logging, or single-step updates.
Exercise
Your server calls a deploy API with a single privileged token. Ten engineers need it, but none of them should hold the token. Which deployment model fits, and what must you add before sharing it?
Show answer
Remote hosting over Streamable HTTP fits, because the token stays on the server. Before sharing it, add authentication so only team members can connect, and per-user identity checks so each caller's actions are limited to what they are allowed to do. Also add logging of who called which tool.
Exercise
Why should the uvx configuration pin a tag or commit instead of tracking the main branch?
Show answer
Pinning gives everyone the same reviewed version and stops unreviewed changes on the main branch from reaching users' machines. You move everyone forward by changing the pin.