Skip to content
MCP & Agentic AI

How to Connect AI Agents to Enterprise Systems Without Exposing Sensitive Data

Most enterprise AI projects stall at the security review, not the demo. This guide explains why custom integrations fail, how the Model Context Protocol fixes the integration layer, and how to build your first governed MCP server step by step.

An AI assistant that only sees what you paste into it is a novelty. One that can check last week's cloud costs, look up a customer's open tickets or find an invoice in the ERP is genuinely useful. Getting from the first to the second is where most enterprise AI initiatives slow down.

The blocker is rarely the model. It is the integration layer: how the agent reaches internal systems, what it is allowed to do there, and whether anyone can prove afterwards what it did. Security teams are right to ask those questions. Hard-coded credentials, broad internal APIs exposed to autonomous tool calls, and operational data copied into external stores create a blast radius no responsible reviewer will accept.

Why custom glue code breaks down

The first integrations are usually bespoke: a function-calling wrapper around an internal API, one per AI client. If your organisation uses GitHub Copilot, Claude and an internal chat bot, you end up maintaining three separate layers for authentication, rate limiting and schema translation. Then the problems compound:

  • Schema drift. Every change to an internal API breaks several agent tool definitions at once.
  • Over-privileged credentials. Agents inherit whatever the wrapped service account can do, which is usually far more than the task needs.
  • No meaningful audit trail. API logs show that a service account called an endpoint, not which person started the session or which request triggered the call.
  • Model lock-in. Switching AI providers means rebuilding every integration.

What the Model Context Protocol changes

The Model Context Protocol (MCP) is an open standard for connecting AI applications to tools and data. Instead of wiring every assistant to every system, you build an MCP server for a system once. It advertises a defined set of capabilities: typed tools the agent can call, resources it can read, and reusable prompts. Any MCP-compatible client can discover and use them.

Governed MCP architecture AI clients connect to MCP servers, which enforce identity, scoped tools, approval and audit logging before calling enterprise systems. AI CLIENTS GitHub Copilot Claude Internal agent MCP GOVERNED MCP SERVER Identity: user's own token Narrow, typed tools Data minimisation Approval for writes Audit log scoped YOUR SYSTEMS Cloud billing & APIs CRM / ticketing ERP Data platform Identity provider (OAuth)
The AI client never holds system credentials. Every request passes through one governed layer that you control and audit.

Two details of the protocol matter for security reviews:

  • Transports. A server can run locally on the user's machine, communicating over standard input/output, or remotely over HTTP using the protocol's Streamable HTTP transport.
  • Authorisation. For HTTP servers, the MCP specification defines authorisation based on OAuth 2.1. The MCP server acts as a resource server, your identity provider issues the tokens, clients use PKCE, and servers must check that each token was issued specifically for them. Tokens must never be passed in URLs. Local stdio servers take credentials from their environment instead.

Step by step: build a governed, read-only MCP server

The example below exposes cloud cost data, a common first use case because it is valuable to engineers and contains little sensitive personal data. The same pattern applies to a CRM, ticketing system or ERP.

  1. Define the tool contract before writing code. List each tool, what it returns, and whether it reads or writes.
    ToolReturnsAccess
    get_unattached_volumesID, size, type and age of unattached disksRead, automatic
    analyze_service_cost_anomalyCost change and affected resource group for one serviceRead, automatic
    create_cleanup_ticketA ticket proposing deletion, for a person to approveWrite, approval required
  2. Give the server least-privilege credentials. On AWS, use an IAM role whose policy allows only what the read tools need. For the first tool, that is a single read action:
    {
      "Version": "2012-10-17",
      "Statement": [{
        "Effect": "Allow",
        "Action": "ec2:DescribeVolumes",
        "Resource": "*"
      }]
    }
  3. Write the server with the official Python SDK. Install it with pip install "mcp[cli]" boto3, then define the tool. Notice that it returns only four fields, with no tags, account IDs or owner names.
    import boto3
    from mcp.server.fastmcp import FastMCP
    
    mcp = FastMCP("finops-readonly")
    
    @mcp.tool()
    def get_unattached_volumes(region: str = "eu-west-1", limit: int = 50) -> list[dict]:
        """List EBS volumes not attached to any instance (status 'available')."""
        ec2 = boto3.client("ec2", region_name=region)
        results = []
        pages = ec2.get_paginator("describe_volumes").paginate(
            Filters=[{"Name": "status", "Values": ["available"]}]
        )
        for page in pages:
            for v in page["Volumes"]:
                results.append({
                    "volume_id": v["VolumeId"],
                    "size_gib": v["Size"],
                    "type": v["VolumeType"],
                    "created": v["CreateTime"].date().isoformat(),
                })
                if len(results) >= limit:
                    return results
        return results
    
    if __name__ == "__main__":
        mcp.run()
  4. Test it with the MCP Inspector before any AI client sees it. The Inspector lists your tools and lets you call them by hand:
    npx @modelcontextprotocol/inspector python server.py
  5. Connect it to an AI client. In VS Code, add the server to .vscode/mcp.json, then open Copilot Chat in Agent mode and check that the tool appears. Newer VS Code versions also support a portable .mcp.json, which uses an mcpServers key instead of servers, so check the format for your version.
    {
      "servers": {
        "finops-readonly": {
          "type": "stdio",
          "command": "python",
          "args": ["${workspaceFolder}/server.py"],
          "env": { "AWS_PROFILE": "finops-readonly" }
        }
      }
    }

    An engineer can now ask "Which unattached volumes in eu-west-1 are older than 90 days?" and the agent calls the tool, for example {"tool": "get_unattached_volumes", "arguments": {"region": "eu-west-1"}}, instead of anyone exporting billing data into a chat window.

  6. Harden it for production. Move to a remote server over Streamable HTTP behind your identity provider with OAuth, so each call runs with the requesting user's identity. Add structured audit logs, rate limits and an approval step for write tools before rolling out beyond a pilot group.
See governed MCP access in practice

Aavya Optima includes an MCP server, so engineering leads can ask Copilot or an internal assistant about cloud spend and carbon, read-only and scoped to their own accounts.

Try Aavya Optima free

Six controls that get you through security review

1. Design narrow tools, not generic ones

A tool called run_sql or call_api gives the agent the same reach as the credentials behind it. Tools like get_unattached_volumes do one thing, return a predictable shape, and are easy to reason about in a review.

2. Separate reading from writing

Start read-only. Put tools that change data in a separate server or permission scope, so access needed to read never quietly grants the ability to write.

3. Act as the user, not as a super-user

Propagate the requesting person's identity, using their OAuth or OIDC token, so your existing access controls decide what the agent can see. It can then never read a record the user couldn't open themselves.

4. Minimise data, and keep it in memory

Fetch data on demand, strip personal data and identifiers the task doesn't need, return only the fields required, and don't persist payloads in the MCP layer. What never enters the conversation can't leak from it, whichever model provider you use.

5. Require approval for consequential actions

For actions that change systems, move money or contact customers, have the server prepare the action and wait for a named person to approve it.

6. Log metadata for every call, and treat tool output as untrusted

Record who called which tool, when, with what parameters and with what outcome. You don't need to store sensitive payloads to have a complete audit trail. Also remember that tool output, such as an email body or web page, can contain instructions written to manipulate the agent (indirect prompt injection, the top risk in OWASP's list for LLM applications). Keep consequential actions behind approval and validate inputs on the server.

For the full list of controls, see our MCP security checklist for enterprises.

A reference architecture

LayerResponsibility
AI clientThe assistant or agent your people use. Holds no system credentials.
MCP serversOne per system or domain. Narrow tools, read/write separated, data minimised.
IdentityOAuth with your identity provider; tokens bound to the server; user identity passed through.
Policy & approvalWhich tools need approval, by whom; rate limits.
AuditWho, what, when and outcome for every call.
Your systemsUnchanged. Existing controls stay in force.

Where to start

Pick one workflow with clear value and low risk, list the minimum data it needs field by field, build one read-only server with two or three narrow tools and logging from day one, and run it with a small group. Review the logs, then add write tools behind approval gates. That sequence produces something security can approve, and a pattern you can repeat for the next system.

Want this built in your environment?

Our forward deployed engineers build governed MCP servers and agent workflows inside your stack, starting with a 2-week Discovery Sprint that delivers one working integration and a production plan. Client data is never used to train AI models.

AI Integration & MCP services

Sources and further reading

Lalit Kumar

Director, Founder & CTO of NeoAavya Consulting Services. A solution architect with 16 years of industry experience, Lalit leads NeoAavya’s technology, including the engineering behind Aavya Optima.

More about Lalit and his articles   Connect on LinkedIn

Read next