Variables
Variables in Pylee provide a flexible way to store and manage dynamic values across your MCP server configurations. They enable you to parameterize server settings, handle environment-specific configurations, and manage sensitive data securely.What are Variables?
Variables are named placeholders that can store values and be referenced throughout your Pylee configuration. They help you:- Avoid repetition: Define values once and reuse them across multiple servers
- Environment flexibility: Use different values for development, staging, and production
- Dynamic configuration: Change server behavior without modifying configuration files
- Template reusability: Create configuration templates that can be customized
Variable Types
Environment Variables
System-level variables that are available to all processes:Configuration Variables
Variables defined within your Pylee configuration for internal use:Runtime Variables
Variables that are computed or set during Pylee execution:- Current timestamp
- User home directory
- System information
- Dynamic paths
Variable Syntax
Basic Substitution
Use${VARIABLE_NAME}
syntax to reference variables:
Default Values
Provide fallback values when variables might be undefined:Nested Variables
Variables can reference other variables:Built-in Variables
Pylee provides several built-in variables that are automatically available:System Variables
${HOME}
: User’s home directory${USER}
: Current username${PWD}
: Current working directory${TMPDIR}
: Temporary directory path
Pylee Variables
${PYLEE_CONFIG_DIR}
: Pylee configuration directory${PYLEE_VERSION}
: Current Pylee version${PYLEE_ENV}
: Environment (development, production, etc.)
Example Usage
Configuration Examples
Development Environment
Production Environment
Multi-Server Configuration
Variable Precedence
Variables are resolved in the following order (highest to lowest precedence):- Command-line arguments: Variables passed via CLI flags
- Environment variables: System environment variables
- Configuration file variables: Variables defined in configuration files
- Built-in variables: Pylee’s predefined variables
- Default values: Fallback values specified in variable references
Advanced Usage
Conditional Variables
Use different values based on conditions:Array Variables
Variables can contain arrays for multiple values:Template Variables
Create reusable server templates:Variable Validation
Type Validation
Ensure variables have the correct type:Required Variables
Mark variables as required:Best Practices
Naming Conventions
- Use descriptive names:
database_connection_string
instead ofdb_conn
- Use consistent casing:
snake_case
for configuration variables - Group related variables:
api_base_url
,api_timeout
,api_version
Organization
- Group variables by purpose or service
- Use comments to document variable usage
- Keep sensitive variables separate from configuration
Documentation
- Document required variables and their purposes
- Provide example values
- Explain variable relationships and dependencies
Security
- Never commit sensitive variables to version control
- Use environment variables for secrets
- Implement proper access controls for configuration files
Troubleshooting
Common Issues
Undefined Variables
Circular References
Type Mismatches
Debugging Variables
Enable variable debugging to see resolution process:Integration with Secrets
Variables work seamlessly with Pylee’s secrets management:Next Steps
- Learn about Secrets for sensitive data management
- Explore Server configuration for advanced server setup
- Check the Troubleshooting guide for common variable issues