Skip to content

Commit 75c22bf

Browse files
committed
docs: streamline auth documentation and add scopes.md references
- Simplify docs/auth.md Cognito section to reference detailed guides - Add scopes.md references throughout README.md for FGAC topics - Improve documentation navigation for authentication and access control
1 parent c3640d9 commit 75c22bf

File tree

2 files changed

+5
-124
lines changed

2 files changed

+5
-124
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ You can deploy the gateway and registry on Amazon EC2 or Amazon EKS for producti
5656
## What's New
5757

5858
* **IdP Integration with Amazon Cognito:** Complete identity provider integration supporting both user identity and agent identity modes. See [detailed Cognito setup guide](docs/cognito.md) for configuration instructions.
59-
* **Fine-Grained Access Control (FGAC) for MCP servers and tools:** Granular permissions system allowing precise control over which agents can access specific servers and tools
59+
* **Fine-Grained Access Control (FGAC) for MCP servers and tools:** Granular permissions system allowing precise control over which agents can access specific servers and tools. See [detailed FGAC documentation](docs/scopes.md) for scope configuration and access control setup.
6060
* **Integration with [Strands Agents](https://github.com/strands-agents/sdk-python):** Enhanced agent capabilities with the Strands SDK
6161
* **Dynamic tool discovery and invocation:** AI agents can autonomously discover and execute specialized tools beyond their initial capabilities using semantic search with FAISS indexing and sentence transformers. This breakthrough feature enables agents to handle tasks they weren't originally designed for by intelligently matching natural language queries to the most relevant MCP tools across all registered servers. [Learn more about Dynamic Tool Discovery →](docs/dynamic-tool-discovery.md)
6262
* **[Installation on EKS](#installation-on-eks):** Deploy on Kubernetes for production environments
@@ -222,7 +222,7 @@ flowchart TB
222222

223223
* **External API Keys (Optional):** One of the example MCP servers uses the [`Polygon`](https://polygon.io/stocks) API for stock ticker data. Get an API key from [here](https://polygon.io/dashboard/signup?redirect=%2Fdashboard%2Fkeys). The server will still start without the API key but you will get a 401 Unauthorized error when using the tools provided by this server.
224224

225-
* **Authentication Setup:** Setup authentication using Amazon Cognito as per instructions [here](docs/auth.md). For detailed Cognito configuration, see the [Cognito setup guide](docs/cognito.md).
225+
* **Authentication Setup:** Setup authentication using Amazon Cognito as per instructions [here](docs/auth.md). For detailed Cognito configuration, see the [Cognito setup guide](docs/cognito.md). For Fine-Grained Access Control (FGAC) configuration, see the [scopes documentation](docs/scopes.md).
226226

227227
## Installation
228228

@@ -288,6 +288,7 @@ The deployment includes these containers:
288288
- Access permissions will be based on the Cognito group you are a member of
289289
- Provides fine-grained access control based on your organizational roles
290290
- For detailed Cognito setup instructions, see [docs/cognito.md](docs/cognito.md)
291+
- For Fine-Grained Access Control (FGAC) configuration and scope management, see [docs/scopes.md](docs/scopes.md)
291292

292293
**Option 2 - Username/Password (Testing Only):**
293294
- Use the traditional login with:

docs/auth.md

Lines changed: 2 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -214,128 +214,8 @@ The above implementation provides an OAuth compliant way to MCP security without
214214

215215
## Amazon Cognito based reference implementation
216216

217-
This section discusses the reference implementation using Amazon Cognito as the IdP, supporting both Machine-to-Machine (M2M) and Session Cookie authentication methods.
218-
219-
>For comprehensive Cognito setup instructions, see [`docs/cognito.md`](cognito.md) which covers both user identity and agent identity authentication modes with step-by-step configuration guides.
220-
221-
### Key Components
222-
223-
#### 1. Auth Server (`auth_server/server.py`)
224-
The auth server provides dual authentication support:
225-
- **Primary Check**: Session cookie validation using `itsdangerous.URLSafeTimedSerializer`
226-
- **Fallback**: JWT token validation with Cognito
227-
- **Group Mapping**: Maps Cognito groups to MCP scopes via `scopes.yml` configuration
228-
- Both M2M and session cookie auth use the same scope definitions
229-
230-
#### 2. CLI Authentication Tool (`agents/cli_user_auth.py`)
231-
A standalone tool for user-based authentication:
232-
- Implements OAuth 2.0 PKCE flow with Cognito hosted UI
233-
- Opens browser for user authentication
234-
- Runs local callback server on port 8080
235-
- Creates session cookie compatible with registry format
236-
- Saves to `~/.mcp/session_cookie` with secure permissions (0600)
237-
238-
#### 3. Agent (`agents/agent.py`)
239-
The agent supports both authentication methods:
240-
- `--use-session-cookie` flag for session-based auth
241-
- `--session-cookie-file` parameter (default: `~/.mcp/session_cookie`)
242-
- Maintains full backward compatibility with M2M authentication
243-
- Automatically includes appropriate headers based on auth method
244-
245-
### 1. Machine-to-Machine Authentication
246-
247-
Cognito supports machine-to-machine authentication, enabling Agents to have their own identity separate from user identity.
248-
249-
#### Implementation Details:
250-
- Reference: [AWS Blog on Machine-to-Machine Authentication](https://aws.amazon.com/blogs/mt/configuring-machine-to-machine-authentication-with-amazon-cognito-and-amazon-api-gateway-part-2/)
251-
- Agents are treated as App Clients (Cognito terminology)
252-
- MCP Server(s) function as resource servers
253-
254-
#### Authentication Flow:
255-
Run the Agent with the following command:
256-
```{.bash}
257-
python agents/agent.py
258-
```
259-
1. Copy `agents/.env.template` to `agents/.env.agent` and set the environment variables (`COGNITO_CLIENT_ID`, `COGNITO_CLIENT_SECRET`, `COGNITO_USER_POOL_ID`) as appropriate for your setup. For detailed Cognito configuration steps, see [`docs/cognito.md`](cognito.md).
260-
1. Agent startup:
261-
- Configured with client ID, client secret, and a set of scopes. _Each agent is an App Client in a Cognito user pool_.
262-
- Requests scopes (e.g., MCP Registry with tool finder and basic MCP servers)
263-
1. Cognito issues a JWT token
264-
1. Agent includes the JWT token in MCP headers
265-
1. Auth server on Nginx side:
266-
- Retrieves JWT token
267-
- Calls Cognito to validate token and get allowed scopes
268-
- Returns 200 or 403 based on:
269-
- URL (MCP server)
270-
- Payload (Tools)
271-
- Agent's allowed scopes
272-
273-
#### Advantages
274-
1. Leverages existing Cognito user identities and groups
275-
1. No need to manage separate M2M credentials for user-initiated actions
276-
1. Maintains user context throughout the session
277-
1. Compatible with existing web-based authentication flow
278-
1. Auth server handles both authentication methods transparently
279-
280-
### 2. Session Cookie Authentication
281-
282-
Session cookie authentication enables agents to act on behalf of users, using their Cognito identity and group memberships for authorization.
283-
284-
#### Implementation Components
285-
286-
##### a. CLI Authentication Tool (`agents/cli_user_auth.py`)
287-
288-
The CLI tool handles the OAuth flow with Cognito and saves the session cookie locally:
289-
290-
```bash
291-
# Run the CLI authentication tool
292-
python agents/cli_user_auth.py
293-
294-
# This will:
295-
# 1. Open your browser to Cognito hosted UI
296-
# 2. After login, capture the authorization code
297-
# 3. Exchange code for user information
298-
# 4. Create and save session cookie to ~/.mcp/session_cookie
299-
```
300-
301-
Required environment variables:
302-
- `COGNITO_USER_POOL_ID`: Your Cognito user pool id
303-
- `COGNITO_CLIENT_ID`: OAuth client ID configured for PKCE flow
304-
- `SECRET_KEY`: Must match the registry's SECRET_KEY for cookie compatibility
305-
306-
##### b. Agent with Session Cookie Support
307-
308-
Copy `agents/.env.template` to `agents/.env.user` and set the environment variables (`COGNITO_CLIENT_ID`, `COGNITO_CLIENT_SECRET`, `COGNITO_USER_POOL_ID`, `SECRET_KEY`) as appropriate for your setup. For detailed Cognito configuration steps, see [`docs/cognito.md`](cognito.md).
309-
310-
The agent (`agents/agent.py`) supports session cookie authentication:
311-
312-
```bash
313-
# Use agent with session cookie
314-
python agent.py \
315-
--use-session-cookie \
316-
--message "What time is it in Tokyo?" \
317-
--mcp-registry-url http://localhost/mcpgw/sse
318-
```
217+
For comprehensive setup instructions and detailed configuration of Amazon Cognito as the Identity Provider, see the detailed documentation in [`docs/cognito.md`](cognito.md) which covers both user identity and agent identity authentication modes with step-by-step configuration guides.
319218

320-
Key features:
321-
- `--use-session-cookie`: Enable session cookie authentication mode
322-
- `--session-cookie-file`: Cookie file path (default: `~/.mcp/session_cookie`)
323-
- Automatically reads cookie and includes in request headers
324-
- Falls back to M2M if session cookie flag not provided
325-
326-
##### c. Auth Server
327-
328-
The auth server validates session cookies alongside JWT tokens:
329-
- Checks for `mcp_gateway_session` cookie in request headers
330-
- Validates cookie signature using `itsdangerous.URLSafeTimedSerializer`
331-
- Maps Cognito groups to MCP scopes using `scopes.yml` configuration:
332-
- Configuration-driven mapping ensures consistency with M2M authentication
333-
- Single source of truth for all permission definitions
334-
- Falls back to JWT validation if no valid cookie found
335-
336-
#### Advantages:
337-
- Simpler implementation compared to user-based authentication
338-
- Enables fine-grained control over Agent permissions
339-
- Facilitates secure machine-to-machine communication within the MCP ecosystem
219+
For information about Fine-Grained Access Control (FGAC) including scope configuration, group mappings, and permission management, see [`docs/scopes.md`](scopes.md).
340220

341221
By implementing these enhancements, we can significantly improve the security, scalability, and flexibility of our MCP authentication and authorization system.

0 commit comments

Comments
 (0)