Executable Standards: Serving Internal Docs via MCP
Passive documentation is often ignored by AI agents. To maintain a "padded cell" for your AI—a safe environment where the model is constrained by your specific engineering physics—you must make your standards accessible directly within the model's context.
By using the Model Context Protocol (MCP) and Python's FastMCP library, you can transform a directory of Markdown files into an interactive resource that the AI can query, read, and follow.
The Implementation
This script scans a standards directory and dynamically registers each Markdown file as a tool, allowing the AI to "discover" your rules as it works.
from fastmcp import FastMCP
import os
# Create the MCP server
mcp = FastMCP("Engineering Standards")
STANDARDS_DIR = "./standards"
# Register a resource for direct access
@mcp.resource("standards://{path}")
def get_standard(path: str) -> str:
with open(os.path.join(STANDARDS_DIR, path), "r") as f:
return f.read()
# Dynamically generate tools for each standard
def register_standards():
for filename in os.listdir(STANDARDS_DIR):
if filename.endswith(".md"):
def tool_func():
return get_standard(filename)
tool_name = f"get_rule_{filename[:-3]}"
mcp.tool(name=tool_name)(tool_func)
register_standards()
if __name__ == "__main__":
mcp.run()
The "Padded Cell" Philosophy
Providing these tools ensures the AI never has to guess your architectural preferences. It enforces compliance by making your standards part of the AI's operational toolset.
Deep Dive
For more on why we use strict standards to govern AI behavior, check out our blog post: The Padded Room: Engineering a Safe Space for AI Agents.