

# Endpoint policies

With the default endpoint policy, you have full access to AWS Context through the endpoint. To restrict access, attach a custom endpoint policy. AWS Context evaluates the endpoint policy together with the caller’s identity-based policies and any resource-based policy on the Agent Context. For more information about endpoint policies, see [Control access to services using endpoint policies](https://docs.aws.amazon.com/vpc/latest/privatelink/vpc-endpoints-access.html) in the *AWS PrivateLink Guide*.

To use the AWS Context MCP server through the endpoint, allow `context-mcp:InvokeMcp` in the endpoint policy. If you don’t allow this action, you can’t send any requests to the MCP server through the endpoint. Each tool call also requires the AWS Context action that the tool calls. The `context-mcp:InvokeMcp` action doesn’t apply to a specific resource, so its `Resource` element must be `"*"`.

**Example – Allow retrieval from one Agent Context**  
With the following JSON endpoint policy, one IAM role can search and retrieve from one Agent Context through the endpoint:

```json
{
  "Version": "2012-10-17",
  "Statement": :role/{{ExampleRole`"
      },
      "Action": [
        "context:SearchAgentContext",
        "context:AgenticRetrieve"
      ],
      "Resource": "arn:aws:context:us-east-1:[replaceable]`111122223333}}:agent-context/[replaceable]`ac-EXAMPLE11111`"
    }
  ]
}
```

**Example – Allow an MCP tool call**  
With the following JSON endpoint policy, one IAM role can use the MCP server through the endpoint and call the search tool on one Agent Context:

```json
{
  "Version": "2012-10-17",
  "Statement": :role/{{ExampleRole`"
      },
      "Action": "context-mcp:InvokeMcp",
      "Resource": "*"
    },
    {
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::[replaceable]`111122223333}}:role/{{ExampleRole`"
      },
      "Action": "context:SearchAgentContext",
      "Resource": "arn:aws:context:us-east-1:[replaceable]`111122223333}}:agent-context/[replaceable]`ac-EXAMPLE11111`"
    }
  ]
}
```

You can also use [AWS global condition context keys](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html) in identity-based policies and Agent Context resource policies to allow requests only when they arrive through your endpoint.