Enables configuration of the policy MCP server through environment variables, allowing customization of policy paths, rude word lists, and other settings via .env files
Integrates with GitHub for installation of the fastmcp SDK directly from the jlowin/fastmcp repository when not available on PyPI
Provides runtime environment for the MCP server with specific integration for different Python environments (Windows vs Dev Container contexts)
Uses YAML files for policy definition and configuration, allowing customizable policy rules that can be enforced through the server's policy compliance tool
Policy MCP Server
AI WARNING: This content includes AI-generated code. Verify for accuracy and security before use.
All prompts to create this project is located under 'prompts' directory.
Overview
A Model Context Protocol (MCP) server following the FAST MCP specification. Modular, secure, XAI-compliant, and fully tested.
Architecture Diagram (ASCII)
Project Structure
Setup
- Install uv (if not installed):
- Create a virtual environment (recommended):
- Install dependencies (including fastMCP SDK):If
fastmcp
is not on PyPI, add this line torequirements.txt
:Then re-run the install command: - Copy
.env.example
to.env
and configure as needed:
Running the Server
This will launch the server using the built-in mcp.run()
entrypoint. (Note: The script will print a warning, but the server will still start.)
FAST MCP Compliance
This server is built using the official fastMCP SDK and reference implementation from https://github.com/jlowin/fastmcp. All protocol endpoints and logic are provided by the SDK. See the referenced repository and documentation for details on the protocol and compliance.
Policy Compliance Tool
This server exposes an enforce_policy
tool, which checks if a requested action is compliant with the policies defined in prompts/policy.prompt.yaml
.
MCP Extension/Client Integration
To use this server with the MCP extension or compatible clients, add the following to your VS Code settings.json
(or your client's MCP config):
- Adjust the paths as needed for your environment.
- The server will use the
POLICY_PATH
and any other environment variables (see below).
Configuration Variables
POLICY_PATH
: Path to the policy YAML file. Defaults to./prompts/policy.prompt.yaml
but can be overridden in your.env
file or MCP config.RUDE_WORDS
: Comma-separated list of rude/abusive words for policy enforcement. Set in.env
or MCP config.
Important: VS Code, Dev Containers, and Python Environments
If you are using VS Code with a Dev Container:
- All development, testing, and running the server from the terminal inside the Dev Container requires
fastmcp
and all dependencies to be installed in the Dev Container environment (Linux). - Use the provided setup instructions to install dependencies inside the container.
If you want to use the MCP extension or configure the MCP server in VS Code (outside the Dev Container):
- The MCP extension launches the server using your Windows Python (e.g.,
P:\Python\Python313\python.exe
), not the Dev Container's Python. - You must also install
fastmcp
and all required dependencies in your Windows Python environment: - Alternatively, update your Windows
PATH
so that the correct Python and installed packages are found by VS Code. - If you see errors like
No module named fastmcp
, it means the extension is using a Python environment that does not have the package installed.
Summary:
- Dev Container: install and test inside the container for Linux-based workflows.
- VS Code MCP extension: ensure your Windows Python has all dependencies for the server to launch and run.
- You may need to maintain both environments if you use both workflows.
Testing the Server
You can test the policy enforcement tool using the MCP extension chat or any compatible client:
- To check a prompt for compliance, type in the chat:
- The server will respond with a compliance result based on your policy configuration and logic.
Example Result Screenshot
MCP Server
Agent Response
Extending the MCP Server
To add a new tool:
See src/server.py
for examples.
License
MIT
This server cannot be installed
A Model Context Protocol server that enforces policies on user inputs by checking against defined rules and rude words, helping ensure AI interactions remain appropriate and compliant.
Related MCP Servers
- AsecurityAlicenseAqualityThis server implements the Model Context Protocol to facilitate meaningful interaction and understanding development between humans and AI through structured tools and progressive interaction patterns.Last updated -1322TypeScriptMIT License
- AsecurityFlicenseAqualityA Model Context Protocol server that allows secure execution of pre-approved commands, enabling AI assistants to safely interact with the user's system.Last updated -1318JavaScript
- -securityFlicense-qualityA Model Context Protocol server that enables role-based context management for AI agents, allowing users to establish specific instructions, maintain partitioned memory, and adapt tone for different agent roles in their system.Last updated -TypeScript
- -securityFlicense-qualityA comprehensive Model Context Protocol server implementation that enables AI assistants to interact with file systems, databases, GitHub repositories, web resources, and system tools while maintaining security and control.Last updated -16TypeScript