Substrate
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Substrateshow me the base classes for creating an MCP server"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Substrate - MCP Foundation Layer
Substrate provides the foundation for building production-grade Model Context Protocol (MCP) servers. It includes base classes, documentation, and patterns that ensure consistent, reliable implementations.
Overview
Substrate is:
Foundation Layer: Base classes and interfaces for all MCP servers
Documentation Server: Serves methodology and architecture documentation
Pattern Library: Common patterns for MCP implementation
Passive Component: Provides structure but no active functionality
Related MCP server: MCP Starter
Features
Base MCP Class: Standard patterns for all MCP servers
Response Builders: Structured response creation
Error Handling: Consistent error patterns
Progress Tracking: Real-time operation feedback
Sampling Support: Intelligent assistance integration
Documentation Loading: Flexible documentation system
Installation
As a Dependency
For use in your MCP server:
pip install substrate-mcpOr in your pyproject.toml:
dependencies = [
"substrate-mcp>=1.0.0",
"fastmcp>=0.1.0"
]For Development
git clone https://github.com/ivan-saorin/substrate
cd substrate
pip install -e .Usage
Creating an MCP Server
from substrate import SubstrateMCP
class YourServer(SubstrateMCP):
def __init__(self):
super().__init__(
name="your_mcp",
version="1.0.0",
description="Your MCP description"
)
self._register_tools()
def _register_tools(self):
@self.tool()
async def your_tool(ctx, param: str):
"""Tool description"""
result = await self.process(param)
return self.create_response(
success=True,
data=result
)Running Substrate Server
# Run the documentation server
python -m substrate
# Or with custom docs
SUBSTRATE_DOCS_DIR=/path/to/docs python -m substrateDocker Usage
FROM python:3.12-slim
# Copy substrate
COPY substrate /substrate
# Copy your MCP
COPY your-mcp /app
WORKDIR /app
# Install both
RUN pip install -e /substrate && pip install -e .
CMD ["python", "-m", "your_mcp"]Documentation System
Substrate can serve different documentation sets:
Bundled Docs: Default examples included with substrate
Custom Docs: Your own methodology and architecture
Custom Documentation
Mount your documentation at runtime:
# Docker
docker run -v ./my-docs:/substrate-docs substrate-mcp
# Local
export SUBSTRATE_DOCS_DIR=./my-docs
python -m substrateYour documentation directory should contain:
atlas.md- Development methodologysystem-design.md- System architecturecomponent-map.json- Component registry
Base Classes
SubstrateMCP
The foundation for all MCP servers:
class SubstrateMCP(FastMCP):
"""Base class providing:
- Response building
- Error handling
- Progress tracking
- Sampling support
"""Response Patterns
# Success response
return self.create_response(
success=True,
data={"result": value},
message="Operation completed"
)
# Error response
return self.create_error_response(
error="Clear error message",
error_type="validation",
suggestions=["Try this", "Check that"]
)Progress Tracking
async with self.progress_context("operation") as progress:
await progress(0.1, "Starting...")
# ... work ...
await progress(0.5, "Halfway...")
# ... more work ...
await progress(1.0, "Complete!")Integration with AKAB
Substrate is designed to work with AKAB for A/B testing:
# In your MCP
result = await ctx.call_tool(
"akab_quick_compare",
prompt="Your prompt",
providers=["anthropic_m", "openai_l"]
)Best Practices
Production-Grade Only: Real implementations, no mocks
Clear Separation: Each MCP does one thing well
Explicit Interfaces: No implicit behaviors
Structured Errors: Always provide actionable feedback
Clean Logging: Use stderr, never stdout
Common Issues
Stdout Pollution
MCP uses JSON-RPC over stdio. Any print() breaks the protocol.
Solution: Log to stderr
logging.basicConfig(stream=sys.stderr)AsyncIO Conflicts
FastMCP manages its own event loop.
Solution: Don't use asyncio.run()
def main():
server = YourServer()
server.run() # Let FastMCP handle asyncExamples
See the included example documentation:
docs/atlas.md- Example development methodologydocs/system-design.md- Example system architecturedocs/component-map.json- Example component structure
Contributing
Follow the Atlas methodology
Ensure all tests pass
Update documentation as needed
Submit PR with clear description
License
MIT License - see LICENSE file for details
This server cannot be deployed
Maintenance
Related MCP Connectors
Model Context Protocol server for the Apideck Unified API. Connect any MCP-compatible agent framework to 100+ accounting systems, HRIS platforms, file storage providers, and more through one integration. More information https://www.apideck.com/mcp-server
A Model Context Protocol (MCP) server for Selise Blocks Cloud integration
A Model Context Protocol server for Wix AI tools
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Related MCP Servers
- AlicenseNot gradedqualityNot gradedmaintenanceA streamlined foundation for building Model Context Protocol servers in Python, designed to make AI-assisted development of MCP tools easier and more efficient.12MIT
- AlicenseDqualityDmaintenanceA foundation for building custom local Model Context Protocol (MCP) servers that provide tools accessible to AI assistants like Cursor or Claude Desktop.137MIT
- AlicenseNot gradedqualityCmaintenanceA production-ready foundation for developing custom Model Context Protocol (MCP) servers in TypeScript. Provides a complete layered architecture pattern, working example implementation, and comprehensive developer infrastructure to connect AI assistants with external APIs and data sources.103 npm72ISC
- AlicenseAqualityCmaintenanceA production-ready foundation for building secure, observable MCP servers with built-in authentication, rate limiting, and reference tools like database-query and semantic-search.1511 npmMIT