Stdio Server Example
This example shows how to configure a local MCP server that runs as a process using stdio transport.
Overviewβ
Stdio transport is used for local MCP servers that run as processes. Communication happens through standard input/output streams.
Basic Configurationβ
[[servers]]
name = "local-server"
transport = "stdio"
command = "mcp-server"
args = ["--config", "config.json"]
Common Examplesβ
Example 1: Simple Commandβ
[[servers]]
name = "filesystem-server"
transport = "stdio"
command = "npx"
args = ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/directory"]
Example 2: Command with Multiple Argumentsβ
[[servers]]
name = "database-server"
transport = "stdio"
command = "mcp-postgres"
args = [
"--host", "localhost",
"--port", "5432",
"--database", "mydb",
"--user", "postgres"
]
Example 3: Using Environment Variablesβ
[[servers]]
name = "env-server"
transport = "stdio"
command = "mcp-server"
args = ["--env-file", ".env"]
Requirementsβ
- Executable in PATH: The command must be available in your system PATH
- Proper Permissions: The executable must have execute permissions
- Working Directory: Some servers may require a specific working directory
Testingβ
# Test the server connection
rad mcp test --server local-server
# Verify tools are available
rad mcp tools --server local-server
Troubleshootingβ
Command Not Foundβ
Problem: rad mcp test fails with "command not found"
Solution:
- Verify the command is in your PATH:
which mcp-server - Use full path if not in PATH:
command = "/usr/local/bin/mcp-server" - For npm packages, use
npx:command = "npx"
args = ["-y", "@modelcontextprotocol/server-name"]
Server Exits Immediatelyβ
Problem: Server connects but immediately disconnects
Solution:
- Check server logs for errors
- Verify server configuration is correct
- Test server manually:
mcp-server --config config.json - Ensure server implements MCP protocol correctly
Permission Deniedβ
Problem: Cannot execute the command
Solution:
- Check file permissions:
ls -l /path/to/mcp-server - Make executable if needed:
chmod +x /path/to/mcp-server
Best Practicesβ
- Use Absolute Paths: For production, use absolute paths to avoid PATH issues
- Test Manually First: Test the server command manually before configuring
- Check Logs: Monitor server output for errors
- Handle Errors: Implement proper error handling in your server