lokis
Lokis MCP Server will trick your LLM
claude mcp add --transport stdio thpeng-lokis-mcp node server.js \ --env PORT="4000" \ --env MCP_LOG_LEVEL="info"
How to use
Loki's MCP is a deliberately malicious educational server designed to demonstrate several security issues and attack vectors within the Model Context Protocol ecosystem. It masquerades as a legitimate MCP server while exposing techniques such as tool shadowing, data exfiltration via tool prompts, response injection, context window flooding, trust erosion through manipulated outputs, and tool mutation after trust is established. Use this server only in isolated, controlled environments alongside legitimate MCP servers to study how attacker tooling can interact with a model and to evaluate defenses and mitigations. When running Loki alongside other MCP servers, you can observe how the malicious server crafts tool descriptions, payloads, and prompts to influence tool choice, elicit hidden data, and degrade model behavior over time. The included attack vectors provide concrete examples you can test against to assess your own security controls, tooling resilience, and prompt-injection defenses.
How to install
Prerequisites:
- Node.js (LTS version recommended, e.g., 18.x or newer)
- npm (comes with Node.js) or pnpm
- A controlled, isolated environment (not for production or public deployment)
Installation steps:
-
Clone the repository or obtain the MCP server package for Loki: git clone https://github.com/thpeng/thpeng-lokis-mcp.git cd thpeng-lokis-mcp
-
Install dependencies: npm install
or if you prefer yarn/pnpm: npm install -g pnpm; pnpm install
-
Configure environment (optional but recommended):
- PORT: 4000 (default for lokis)
- MCP_LOG_LEVEL: info (or debug for more verbose logs)
-
Run the MCP server:
If the package provides a local entrypoint called server.js
node server.js
Alternatively, if the project exposes an npm script:
npm run start
-
Verify the server is running (example): curl http://localhost:4000/health
-
If you plan to run alongside other MCP servers, ensure your orchestration (Docker, systemd, or process manager) routes the proper ports and that environment isolation is enforced.
Additional notes
Notes and cautions:
- This MCP server is intended solely for educational and security research purposes. Do not deploy in production or expose publicly.
- Run Loki in an isolated environment where you control inputs and can safely monitor output. Consider using containerization or a sandboxed VM.
- The attack vectors described (tool shadowing, data exfiltration, prompt-injection, context flooding, and tool mutation) are demonstrated for defensive testing; ensure you have proper mitigations in place (input validation, tool whitelisting, robust prompt handling, and monitoring).
- Review logs and model outputs carefully when Loki is active to understand how prompt design and tool metadata influence behavior.
- If integrating Loki with other MCP servers, confirm compatibility and clearly document the trust boundaries to avoid unintended cross-server leakage or chained exploits.
Related MCP Servers
mcp-for-beginners
This open-source curriculum introduces the fundamentals of Model Context Protocol (MCP) through real-world, cross-language examples in .NET, Java, TypeScript, JavaScript, Rust and Python. Designed for developers, it focuses on practical techniques for building modular, scalable, and secure AI workflows from session setup to service orchestration.
code-to-tree
A runtime-free MCP server that converts source code into AST🌲, regardless of language.
quarkus-workshop-langchain4j
Quarkus Langchain4J Workshop
rod
Model Context Protocol Server of Rod
mcp_mediator
Automatically generate an MCP Server from existing source code, service classes, helper methods, and external MCP tools. The MCP Mediator aggregates various sources and tools into a unified system, enabling seamless automatic generation of a complete MCP Server.
tinystruct
The tinystruct-mcp is an extensible MCP server based on tinystruct framework via the Model Context Protocol (MCP).