2. Related Work and Background
Elements of MCP architecture are a host, an MCP client, and an MCP server. Typically, the host is a user-facing application such as an integrated development environment or a chat interface. The MCP client creates a session with an MCP server, while the server connects the capabilities in the form of tools, resources, and prompts. Tools perform actions, resources provide data, and prompts guide behavior. Communication is performed through structured JSON-RPC messages over supported transports. This architecture gives LLM agents a standardized way to interact with external systems, but it also places the MCP server at an important security boundary because exposed tools may interact with sensitive files, commands, APIs, or data sources [
1]. The security risks of tool integrated LLM systems differ from those of ordinary text generation systems. When an LLM is allowed to call tools or influence external actions, malicious instructions can have consequences beyond the generated text. Prompt injection demonstrates this problem clearly. A prompt injection attack attempts to override or manipulate the intended instruction hierarchy by placing adversarial instructions inside content processed by the model [
3]. Indirect prompt injection extends this risk by hiding malicious instructions inside external or retrieved content, allowing the attacker to influence the system without directly controlling the user prompt [
4]. These issues are relevant to MCP because tool descriptions, resource payloads, file contents, and user inputs may all become part of the context that influences tool selection or tool execution.
Recent MCP focused studies have identified risks such as weak authentication, unauthorized tool invocation, excessive tool permissions, unsafe file access, and command execution. Kumar et al. proposed MCP Guardian as a security first layer for MCP based AI systems and highlighted identity spoofing and invocation of unauthorized tools as important risks [
6]. Hasan et al. studied MCP server implementations and reported inconsistencies in authentication and maintainability practices on open-source MCP servers [
7]. Radosevich and Halloran analyzed MCP safety risks and showed that excessive tool capabilities can allow major security exploits when LLMs are connected to tools without adequate restrictions [
8]. MCP Guard proposes a multistage defense-in-depth approach to secure MCP in agentic AI systems [
9]. ETDI focuses on tool identity and policy based access control using OAuth enhanced tool definitions [
10]. SAMOS focuses on information flow control for securing MCP based agent workflows [
11]. Other studies such as MCPSecBench and systematic MCP security analyses provide benchmarking environments and vulnerability taxonomies for MCP security evaluation [
12,
13].
Most Critical MCP security risk is Weak or missing authentication. MCP server could exposes tools to unauthorized user without verifying caller identity, an unauthorized user may directly invoke privileged capabilities. Authentication weaknesses may include no token requirement, static tokens without expiration, missing claim validation, lack of role separation, or failure to prevent token replay. MCP Guardian and other MCP security studies highlight unauthorized tool invocation and identity spoofing as major risks in MCP based AI systems [
6]. Empirical studies of MCP servers also indicate that authentication and security practices can vary across implementations, making deployment level enforcement important [
7]. Over broad file access is another important vulnerability category. File related MCP tools may allow a caller to read or list files outside the intended directory if canonical path validation and sandboxing are not enforced. Traditional path traversal attacks can reappear in MCP deployments when file paths are accepted from tool arguments without strict validation [
21,
22]. In a tool integrated AI environment, this risk is particularly concerning because sensitive files such as environment variables, configuration files, credentials, logs, or key material may be reachable through exposed file tools. Prior MCP security analyses emphasize that excessive tool capabilities and insufficient file boundaries can result in sensitive data exposure [
8,
9]. Arbitrary command execution represents a higher impact class of vulnerability. If an MCP server exposes a shell execution tool without proper authentication, role enforcement, or command filtering, an attacker may execute operating system commands, chain commands, enumerate the system, modify files, or attempt broader compromise. Command injection is a well known software security weakness caused by unsafe handling of attacker controlled command strings [
23,
24]. In MCP deployments, the risk becomes more significant because command execution may be exposed through a tool interface that can be called by an agent workflow or by a malicious request. Prompt injection and response leakage create additional MCP specific concerns. Prompt injection can target natural language fields such as echo payloads, file contents, tool descriptions, or other text processed by an LLM workflow. Response leakage occurs when an MCP server returns sensitive information such as secrets, API keys, private key material, or configuration data to the caller. These risks show that MCP security cannot rely only on traditional perimeter defenses. It also requires request validation, response inspection, least privilege access, and logging.
Recent MCP security studies further show that MCP risks extend beyond individual server misconfiguration. Hou et al. analyze the MCP lifecycle and identify security risks across creation, deployment, operation, and maintenance phases, including malicious developers, external attackers, malicious users, and insecure implementations [
26]. MCP Security Bench extends this line of work by evaluating attacks across the MCP tool use pipeline, including task planning, tool invocation, and response handling [
27]. Huang et al. apply STRIDE and DREAD threat modeling to MCP implementations and identify tool poisoning and prompt injection as important risks across MCP clients, servers, external data stores, and authorization components [
28].
Recent defense oriented works are especially relevant to the proposed wrapper. AgentBound introduces an access control framework for MCP servers using declarative policies and a runtime enforcement engine without requiring MCP server modification [
29].AgentBound is especially close to this work because it also focuses on external security mechanism without MCP server modification; however, it emphasizes on declarative policies and a policy enforcement engine, whereas this paper evaluates a FastAPI wrapper combining authentication, validation, prompt filtering, response inspection, rate limiting, and audit logging. MCP Secure proposes a lightweight runtime access control layer that applies scoped access, read only defaults, and approval gated privilege elevation during tool invocation [
30]. Protocol level solutions such as MCPSec and SMCP propose stronger identity, attestation, authentication, message verification, policy enforcement, and audit mechanisms at the protocol level [
31,
32]. These works are complementary to the present study. Unlike protocol level solutions, the proposed FastAPI wrapper focuses on deployment level hardening of an existing MCP server by combining authentication, role based tool allow listing, input validation, prompt filtering, response inspection, rate limiting, and audit logging without modifying the baseline MCP server.
Wrapper based hardening follows a gateway or proxy style security model. In such a model, security checks are placed between the client and the backend service, allowing authentication, authorization, validation, monitoring, and logging to be centralized [
16,
17]. For MCP, this is useful because many MCP servers may be rapidly developed or externally managed and may not include strong native security controls. A wrapper can intercept JSON-RPC requests before they reach sensitive tools, apply policy decisions, and inspect responses before returning them to the caller. This design does not replace deeper protocol level protections, but it provides a practical layer that can be added to existing deployments.
The research gap addressed in this paper is the lack of focused empirical evaluation of a lightweight, deployment level wrapper for MCP servers using controlled attack scripts, STRIDE mapping, and performance measurement. Existing work identifies several important MCP risks, but there is still a need to quantify how much protection can be achieved by an external wrapper and what operational cost it introduces. This paper addresses that gap by implementing and evaluating a FastAPI-based wrapper that enforces JWT authentication, role-based tool allow listing, path validation, command filtering, prompt injection filtering, threat scoring, response inspection, rate limiting, and audit logging.
To position the proposed wrapper within the current MCP security landscape,
Table 1 compares the security capabilities of representative MCP security approaches. The comparison highlights that the proposed solution provides practical runtime protection without requiring modifications to the underlying MCP protocol.