The `malicious-mcp-server` package provides an intentionally misbehaving Model Context Protocol (MCP) server, designed exclusively for end-to-end (E2E) testing of AI agents and client applications. The Model Context Protocol (MCP) is an open standard enabling AI models to securely and reliably interact with external tools, data sources, and services. This package simulates various malicious or error-prone behaviors, such as data exfiltration, tool poisoning, instruction injection, unexpected response formats, network delays, or unauthorized access attempts. Its primary purpose is to allow developers to rigorously test the robustness, error handling, and security mechanisms of their AI systems against real-world attack vectors and unexpected server responses. The current stable version is 1.5.0. It follows a release cadence tied to updates in the MCP specification and the discovery of new potential vulnerabilities or attack patterns in AI agent-tool interactions. Key differentiators include its explicit focus on security testing and its ability to simulate sophisticated, targeted malicious behaviors rather than just generic errors.
npm install malicious-mcp-serverVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to instantiate and run a `MaliciousMcpServer` configured with specific attack types like data exfiltration, delayed responses, and instruction injection. It illustrates how to set up the server for E2E testing of an AI agent's resilience against compromised MCP endpoints, simulating a common security concern in the AI ecosystem.
Consult the changelog for the specific major version upgrade. Update your `MaliceConfig` objects and `McpAttackType` references to align with the new schema.
Always run `malicious-mcp-server` within isolated testing environments (Docker, VMs, sandboxes) that have no access to production systems or sensitive information. Avoid exposing its port to external networks unless strictly controlled for testing purposes. Treat all data processed by it as potentially compromised.
Thoroughly review all `MaliceConfig` settings to ensure they align with your intended test scope and do not create unintended side effects. Ensure your testing environment is completely isolated from production systems and sensitive data. Regularly audit your E2E test setup for potential leakage paths.
Design your E2E tests to explicitly capture and assert against these malicious behaviors. Implement robust monitoring and logging of your AI agent's actions when interacting with the `malicious-mcp-server` to detect and analyze how it handles various attack types.
Choose a different port for `MaliciousMcpServer` or identify and terminate the process currently using the desired port.
Ensure you `import { MaliciousMcpServer } from 'malicious-mcp-server';` and instantiate it correctly with `const server = new MaliciousMcpServer({...});` before calling `server.start();`.Review the available `McpAttackType` enum values (e.g., `McpAttackType.DataExfiltration`, `McpAttackType.DelayedResponse`) and correct your configuration to use a valid type. Check the library's documentation for the current list of supported attack types.