Skip to content

Commit 4674482

Browse files
committed
Refined auth docs;
1 parent 73def6b commit 4674482

File tree

1 file changed

+32
-34
lines changed

1 file changed

+32
-34
lines changed

docs/auth.md

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ graph LR
2424
Agent[AI Agent]
2525
2626
%% CLI Auth Tool
27-
CLIAuth[CLI Auth Tool<br/>cli_auth.py]
27+
CLIAuth[CLI Auth Tool]
2828
2929
%% Identity Provider
3030
IdP[Identity Provider]
@@ -187,14 +187,42 @@ A standalone tool for user-based authentication:
187187
- Creates session cookie compatible with registry format
188188
- Saves to `~/.mcp/session_cookie` with secure permissions (0600)
189189

190-
#### 3. Enhanced Agent (`agents/agent_w_auth.py`)
191-
The agent now supports both authentication methods:
190+
#### 3. Agent (`agents/agent_w_auth.py`)
191+
The agent supports both authentication methods:
192192
- `--use-session-cookie` flag for session-based auth
193193
- `--session-cookie-file` parameter (default: `~/.mcp/session_cookie`)
194194
- Maintains full backward compatibility with M2M authentication
195195
- Automatically includes appropriate headers based on auth method
196196

197-
### 1. Machine-to-Machine (M2M) Authentication
197+
### 1. Machine-to-Machine Authentication
198+
199+
Cognito supports machine-to-machine authentication, enabling Agents to have their own identity separate from user identity.
200+
201+
#### Implementation Details:
202+
- 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/)
203+
- Agents are treated as App Clients (Cognito terminology)
204+
- MCP Server(s) function as resource servers
205+
206+
#### Authentication Flow:
207+
1. Agent startup:
208+
- Configured with client ID, client secret, and a set of scopes
209+
- Requests scopes (e.g., MCP Registry with tool finder and basic MCP servers)
210+
2. Cognito issues a JWT token
211+
3. Agent includes the JWT token in MCP headers
212+
4. Auth server on Nginx side:
213+
- Retrieves JWT token
214+
- Calls Cognito to validate token and get allowed scopes
215+
- Returns 200 or 403 based on:
216+
- URL (MCP server)
217+
- Payload (Tools)
218+
- Agent's allowed scopes
219+
220+
#### Advantages
221+
1. Leverages existing Cognito user identities and groups
222+
2. No need to manage separate M2M credentials for user-initiated actions
223+
3. Maintains user context throughout the session
224+
4. Compatible with existing web-based authentication flow
225+
5. Auth server handles both authentication methods transparently
198226

199227
### 2. Session Cookie Authentication
200228

@@ -252,36 +280,6 @@ The auth server validates session cookies alongside JWT tokens:
252280
- `mcp-server-{name}` → server-specific execute access
253281
- Falls back to JWT validation if no valid cookie found
254282

255-
#### Advantages
256-
1. Leverages existing Cognito user identities and groups
257-
2. No need to manage separate M2M credentials for user-initiated actions
258-
3. Maintains user context throughout the session
259-
4. Compatible with existing web-based authentication flow
260-
5. Auth server handles both authentication methods transparently
261-
262-
### 3. Machine-to-Machine Authentication
263-
264-
Cognito supports machine-to-machine authentication, enabling Agents to have their own identity separate from user identity.
265-
266-
#### Implementation Details:
267-
- 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/)
268-
- Agents are treated as App Clients (Cognito terminology)
269-
- MCP Server(s) function as resource servers
270-
271-
#### Authentication Flow:
272-
1. Agent startup:
273-
- Configured with client ID, client secret, and a set of scopes
274-
- Requests scopes (e.g., MCP Registry with tool finder and basic MCP servers)
275-
2. Cognito issues a JWT token
276-
3. Agent includes the JWT token in MCP headers
277-
4. Auth server on Nginx side:
278-
- Retrieves JWT token
279-
- Calls Cognito to validate token and get allowed scopes
280-
- Returns 200 or 403 based on:
281-
- URL (MCP server)
282-
- Payload (Tools)
283-
- Agent's allowed scopes
284-
285283
#### Advantages:
286284
- Simpler implementation compared to user-based authentication
287285
- Enables fine-grained control over Agent permissions

0 commit comments

Comments
 (0)