Overview
Let’s say you’re building a weather server. You might want users to customize their preferred temperature unit (Celsius vs Fahrenheit), provide an API key for external weather services, or set their default location. Session configurations let you define these customizable parameters - each user connection gets its own configuration that doesn’t affect other sessions, perfect for passing secrets and personalizing behavior. When you provide a configuration schema, Smithery will:- Generate a configuration UI with appropriate form elements (text inputs, dropdowns, checkboxes, number fields)
- Pass configurations to your server as URL parameters using dot notation
- Show helpful descriptions as form labels and tooltips
- Apply default values and enforce required fields
Configuration is passed to your server through URL parameters using dot notation (e.g.,
?apiKey=xxx&model.name=gpt-4
). Users can easily customize these settings through the Smithery interface when connecting to your server.Defining Configuration
How you define your configuration schema depends on your deployment method:- Smithery CLI (TypeScript & Python): Schema automatically extracted from Zod/Pydantic schemas in your code
- Custom Container (Any language): Manual schema definition in
smithery.yaml
file - External MCP: Expose schema via
/.well-known/mcp-config
endpoint
Smithery CLI Approach
For TypeScript and Python servers using Smithery’s managed deployment With Smithery CLI, configuration schemas are automatically extracted from your code - no need to manually define them.- TypeScript with Zod
- Python with Pydantic
Export a
configSchema
from your server entry point:- Configuration schema is automatically extracted from your Zod/Pydantic definitions
- No manual configuration needed
- Schema validation and UI generation handled automatically
Custom Container Approach
For any programming language using Docker containers With custom containers, you manually define configuration schemas in yoursmithery.yaml
file.
smithery.yaml
configSchema
supports all standard JSON Schema features:
- Data types (
string
,number
,boolean
, etc.) - Required fields and default values
- Min/max constraints and enums
- Descriptive titles and documentation
- Manual schema definition required in
smithery.yaml
- Must use
runtime: "container"
deployment mode - Full control over Docker environment and dependencies
Well-Known Endpoint Approach
External MCPs or custom containers can enable configuration forms by exposing a JSON Schema at a well-known endpoint.The Smithery CLI approaches above also provide a
/.well-known/mcp-config
endpoint - it’s simply automatically generated for you based on your schema definitions.1. Create the Schema Endpoint
Your server must expose a JSON Schema at:2. Schema Structure
$schema
: Must reference JSON Schema Draft 07$id
: Your schema’s canonical URLx-query-style
: How parameters are formatted (use “dot+bracket”)properties
: Define your configuration fieldsrequired
: List mandatory fields
Using Configuration in Your Server
Smithery CLI: Automatic Injection
- TypeScript
- Python
Configuration is automatically injected into your
createServer
function:Custom Container & Well-Known Endpoint: Manual Parsing
Your MCP server receives configuration as URL parameters using dot notation:Using Smithery Libraries
- TypeScript
- Python
Manual Parsing
If not using our libraries, you’ll need to parse dot notation parameters manually by:- Splitting parameter names by
.
to handle nested objects - Parsing JSON values to handle booleans and numbers
- Skipping reserved parameters (
api_key
,profile
)
Best Practices
Schema Design
Schema Design
- Use descriptive titles and descriptions - These become form labels and help text
- Set appropriate defaults - Make configuration as simple as possible
- Use enums for fixed options - This creates dropdown menus
- Group related settings - Use nested objects for logical grouping
- Keep required fields minimal - Only require what’s absolutely necessary
Security & Validation
Security & Validation
- Never log sensitive values - Treat API keys and tokens as secrets
- Validate server-side - Always validate input even though Smithery validates too
- Use HTTPS - Always serve your schema and MCP endpoint over HTTPS
- Handle secrets securely - Never expose sensitive configuration values
- Handle parsing errors gracefully - Invalid configuration shouldn’t crash your server
- Use proper constraints - Set min/max values, required fields, and data types appropriately
Approach-Specific Tips
Approach-Specific Tips
Smithery CLI:
- Use descriptive Zod/Pydantic field descriptions (these become UI help text)
- Leverage schema validation features (
.min()
,.max()
,.email()
etc.) - Make frequently-used settings optional with defaults
- Follow JSON Schema standards for proper type definitions
- Test your schema to ensure it generates the expected UI
- Handle dot notation parsing and JSON type conversion gracefully
Testing Your Configuration
- Validate your schema - Use online JSON Schema validators for custom schemas
- Test the endpoint - For Well-Known approach, ensure
/.well-known/mcp-config
is accessible - Verify parsing - Test with sample configurations to ensure correct parsing
- Check the UI - Confirm the generated form matches your expectations
Troubleshooting
Smithery CLI Issues
Smithery CLI Issues
Configuration not detected?
- TypeScript: Export
configSchema
from the same file as yourcreateServer
function - Python: Use the
@smithery.server(config_schema=YourSchema)
decorator - Check that your schema is a valid Zod object or Pydantic BaseModel
- Make sure your
createServer
function accepts{ config }
parameter - Use
z.infer<typeof configSchema>
for the config type
- Ensure you’re using
ctx: Context
parameter in your tool functions - Access config via
ctx.session_config
, not directly
Custom Container & Well-Known Issues
Custom Container & Well-Known Issues
Configuration not parsing?
- Verify your server correctly parses dot notation parameters
- For schema issues, ensure valid JSON Schema syntax
- Check that
/.well-known/mcp-config
returns valid JSON (Well-Known approach) - Test with a simple configuration first
- Ensure your schema has valid JSON Schema syntax
- Test your schema with an online JSON Schema validator
- Check that required fields are properly specified
Common Questions
Common Questions
Can I change configuration mid-session?
No, configurations are bound at connection time. Establish a new connection for different settings.Can configurations be optional?
Yes, in all approaches:
- Smithery CLI: Use optional Zod/Pydantic fields with
.optional()
or default values - Custom Container & Well-Known: Don’t include fields in the
required
array, providedefault
values
See Also
- TypeScript Deployment - Deploy TypeScript servers with Smithery CLI
- Python Deployment - Deploy Python servers with Smithery CLI
- Custom Container Deployment - Deploy servers using Docker containers
- External MCPs - Publishing self-hosted MCPs on Smithery
- Project Configuration - Complete
smithery.yaml
reference - JSON Schema Documentation - Learn more about JSON Schema