local_config.json or a custom-named JSON file) or by setting environment variables that map to the ServerConfig model.
Understanding ServerConfig
The ServerConfig Pydantic model (found in config.py) is the backbone of your server’s setup. It defines crucial aspects of how your server behaves. Here are some of ahe key parameters:
name: A descriptive name for your MCP server (e.g., “My Development MCP”).description: A brief description of your server.type: Specifies the server deployment type. Common values:"local": A server that loads applications based on the local configuration file. Ideal for development and self-hosting."agentr": A server that connects to the AgentR platform to fetch app configurations and manage integrations.
transport: The communication protocol the server will use. Common values:"stdio": Standard input/output, often used for local CLI tools."sse": Server-Sent Events, suitable for web-based clients (like the Playground)."http": A standard HTTP server.
port: The network port on which the server will listen (e.g.,8005). This is applicable forsseandhttptransports.apps: (Primarily forLocalServer) A list ofAppConfigobjects, defining which applications the server should load and how they are configured.- Each
AppConfigspecifies thenameof the application (slug) and can include anintegrationblock.
- Each
store: (Optional) AStoreConfigobject defining the default credential storage mechanism (e.g.,memory,environment,keyring).api_key: (Primarily forAgentRServer) Your AgentR API key if you’re using theagentrserver type.debug: Boolean to enable debug mode (TrueorFalse).log_level: Logging level (e.g., “INFO”, “DEBUG”).
Creating a Server Configuration File
For aLocalServer, you typically create a JSON file (e.g., local_config.json) that defines your server’s settings.
Example local_config.json for a LocalServer:
- We’re setting up a
LocalServernamed “MyFirstMCP Server”. - It will use Server-Sent Events (
sse) on port8005. - It uses an in-
memorystore for credentials (credentials will be lost when the server stops). - It’s configured to load two applications:
zenquotes: This app might not require explicit integration if it’s a public API or configured within its package.tavily: This app uses anapi_keyintegration. Theintegrationblock specifies that the API key namedTAVILY_API_KEYshould be sourced from anenvironmentvariable store (meaning it will look for an environment variable namedTAVILY_API_KEY).
Server Types and Configuration
LocalServer:- Relies heavily on the
appsarray within your configuration file to know which applications (and their tools) to load. - You define integrations (like API keys) directly within the
AppConfigfor each app.
- Relies heavily on the
AgentRServer:- Typically fetches its application configurations from the AgentR platform using your
AGENTR_API_KEY. - Integrations are often managed through the AgentR platform itself.
- Typically fetches its application configurations from the AgentR platform using your
LocalServer as it’s excellent for development and understanding the core mechanics. Refer to servers/server.py for more information.
With your configuration file ready, you’re set to launch the server!