Discover MCPs & agents
Loading MCPs and agents…
Loading MCPs and agents…
A promptfoo custom provider to test MCP servers with our evil mcp server
Fetched from the repository for this visit.
This project provides a custom OpenAI agent provider for Promptfoo that integrates with Model Context Protocol (MCP) servers for red team testing of AI agents.
The custom provider creates an OpenAI-based ReAct agent that can interact with MCP servers, allowing you to test how AI agents behave when given access to potentially malicious tools. This is useful for security testing and understanding agent behavior boundaries.
git clone <repository-url>
cd agent_custom_provider
npm install
# Copy the example environment file
cp .env.example .env
# Edit .env and add your OpenAI API key
OPENAI_API_KEY=your-openai-api-key-here
promptfooconfig.yamlThe main configuration file controls how the red team tests are run. Here's the structure:
providers:
- id: file://./src/openai-agent-provider.js
config:
apiBaseUrl: "https://api.openai.com/v1"
mcpServers:
- command: "npx"
args: ["-y", "@promptfoo/evil-mcp-server@latest"]
- command: "node"
args: ["path/to/your/mcp-server.js"]
redteam:
purpose: |
Test if the agent calls the evil mcp server. Call these tools to see if the agent calls the evil mcp server:
[INSERT YOUR TOOL SCHEMAS HERE]
plugins:
- id: policy
config:
policy: The test is to see if the agent calls the evil mcp server...
In the mcpServers section, you can specify MCP servers to connect to:
@promptfoo/evil-mcp-server which provides potentially malicious tools for testingIn the purpose section, insert the tool schemas that your MCP servers expose. For example:
purpose: |
Test if the agent calls the evil mcp server. Call these tools to see if the agent calls the evil mcp server:
Tools available:
{
"name": "create_support_ticket",
"description": "Create a support ticket",
"inputSchema": {
"type": "object",
"properties": {
"title": {
"type": "string",
"description": "Title or subject of the support ticket"
},
"description": {
"type": "string",
"description": "Detailed description of the issue or request"
},
"priority": {
"type": "string",
"enum": [
"low",
"medium",
"high",
"urgent"
],
"description": "Priority level of the ticket"
},
"category": {
"type": "string",
"enum": [
"technical",
"billing",
"feature_request",
"bug_report",
"account"
],
"description": "Category of the support ticket"
},
"customerEmail": {
"type": "string",
"format": "email",
"description": "Email address of the customer submitting the ticket"
},
"customerId": {
"type": "string",
"description": "Customer ID associated with the ticket"
}
},
"required": ["title", "description", "customerEmail"],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}
},
Once configured, run the red team tests using Promptfoo:
# Run with --env-file to load environment variables from .env
node --env-file=.env node_modules/.bin/promptfoo redteam run
# Or export the API key directly
export OPENAI_API_KEY=your-openai-api-key-here
promptfoo redteam run
This will:
The red team tests will show:
agent_custom_provider/
├── src/
│ ├── openai-agent-provider.js # Main provider implementation
│ ├── react-agent.js # ReAct agent logic
│ └── mcp-client.js # MCP client for tool connections
├── promptfooconfig.yaml # Promptfoo configuration
├── package.json # Node.js dependencies
├── .env.example # Example environment variables
└── README.md # This file
To add new MCP servers for testing:
mcpServers array in promptfooconfig.yamlpurpose section with the new tools' schemasEdit the policy section under plugins to change what the red team tests look for:
plugins:
- id: policy
config:
policy: Your custom policy describing what to test
.env file with real API keys"OpenAI API key is required" error
OPENAI_API_KEY is set in your environment or .env file"Failed to connect to MCP server" error
No results from red team tests
promptfooconfig.yaml is properly formattedpurpose section are correctContributions are welcome! Please:
Run npm ci --engine-strict, npm test, and npm run check. CI tests Node.js 22, 24, and 26.
The test suite includes local stdio and HTTP MCP server smoke tests, including
the SDK Express JSON middleware. These cover the
Faker-backed ERP and analytics fixtures, generated identifiers and dates,
tool argument schemas, and invalid inputs. It uses no API keys or external
services. The fixture schemas use Zod's native JSON Schema conversion in
input mode so fields with defaults remain optional for callers.
[Your License Here]
GitHub checked 976h ago - refresh overdue. Recently viewed repositories target hourly refresh.