Skip to content

Commit 4b5f1ee

Browse files
authored
docs: update AI use cases for MCP SDK v2 and mcp-auth 1.0 (#1492)
1 parent feaf329 commit 4b5f1ee

10 files changed

Lines changed: 205 additions & 246 deletions

docs/use-cases/ai/README.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ description: Explore how Logto can help you build secure, AI-enabled experiences
55
---
66

77
import Catalog from './fragments/_catalog.mdx';
8+
import ExploreAiSolutions from './fragments/_explore-ai-solutions.mdx';
89

910
# AI integration use cases with Logto
1011

12+
<ExploreAiSolutions />
13+
1114
<Catalog />

docs/use-cases/ai/connect-your-agent-to-third-party-apis.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@ sidebar_position: 4
33
sidebar_label: Connect your agent to third-party APIs
44
---
55

6+
import ExploreAiSolutions from './fragments/_explore-ai-solutions.mdx';
7+
68
# Connect your AI agent to third-party APIs
79

10+
<ExploreAiSolutions />
11+
812
This guide walks you through enabling your AI agent to access third-party APIs (e.g., Google Calendar, GitHub, etc.) on behalf of users. By leveraging Logto's social connectors and Secret Vault, you can securely store and manage access tokens, allowing your agent to perform automated tasks without repeatedly asking users to re-authenticate.
913

1014
You'll learn how to:

docs/use-cases/ai/enable-third-party-ai-agent-access.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ sidebar_label: Enable third-party AI agent access to app
44
---
55

66
import ConfigureThirdPartyAiAgent from './fragments/_configure-third-party-ai-agent.mdx';
7+
import ExploreAiSolutions from './fragments/_explore-ai-solutions.mdx';
78

89
# Enable third-party AI agent access to your app
910

11+
<ExploreAiSolutions />
12+
1013
This guide walks you through integrating Logto with your service and enabling AI agents to access it.
1114

1215
You'll learn how to:

docs/use-cases/ai/fragments/_configure-third-party-ai-agent.mdx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,17 @@ You can manually create a third-party app in Logto Console for testing purposes
5959
1. Sign in to your Logto Console.
6060
2. Go <CloudLink to="/applications">**Applications**</CloudLink> → **Create application****Third-party app** -> **OIDC**.
6161
3. Fill in the app name and other required fields, then click **Create application**.
62-
4. Click **Permissions** tab, in the **User** section, click "Add".
63-
5. In the opened dialog -> **User data** -> select **`profile`**, **`email`** permissions, then click **Save**.
64-
6. In the third-party app, configure scopes to request `openid profile email` permissions (scopes).
62+
4. Click the **Permissions** tab to grant [permissions](/integrate-logto/third-party-applications/permission-management) to the app:
6563

66-
**Note**: `openid` is required for OIDC, and `profile` and `email` are the permissions you added in the previous step.
64+
- **User** section: user data permissions such as **`profile`** and **`email`**, for basic identity claims.
65+
- **API resource** section: permissions (scopes) of the [API resources](/authorization/global-api-resources) you've defined in Logto, e.g., the API resource that represents your {props.serviceName ?? 'service'}.
66+
- **Organization** section: organization permissions, if you use Logto organizations.
6767

68-
7. Configure the **redirect URI** of your third-party application accordingly. Remember to update the redirect URI in Logto as well.
68+
5. In the third-party app, configure scopes to request the permissions you granted, e.g., `openid profile email` plus the API resource scopes.
69+
70+
**Note**: `openid` is required for OIDC. To receive an access token bound to an API resource, the app must also include the `resource` parameter in the authorization request. MCP clients that follow the latest MCP specification do this automatically based on the protected resource metadata.
71+
72+
6. Configure the **redirect URI** of your third-party application accordingly. Remember to update the redirect URI in Logto as well.
6973

7074
<img
7175
src="/img/assets/third-party-app-permissions.png"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:::tip
2+
Explore [Logto's AI solutions](https://logto.io/ai): authentication and authorization for MCP servers, AI agents, and apps.
3+
:::

docs/use-cases/ai/fragments/_mcp-prerequisites.mdx

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,35 @@ import Mermaid from '@theme/Mermaid';
33
## Prerequisites \{#prerequisites}
44

55
- A [Logto Cloud](https://cloud.logto.io) (or self-hosted) tenant
6-
- Node.js or Python environment
6+
- Node.js >= 20 environment
77

88
### Understanding the architecture \{#understanding-the-architecture}
99

10-
- **MCP server**: The server that exposes tools and resources to MCP clients.
11-
- **MCP client**: A client used to initiate the authentication flow and test the integration. {<b>{props.isThirdParty ? 'The third-party AI agent will be used as the client in this guide.' : "We'll use the MCP Inspector as the client in this guide."}</b>}
12-
- **Logto**: Serves as the OpenID Connect provider (authorization server) and manages user identities.
10+
- **MCP server**: The server that exposes tools and resources to MCP clients. Following the [latest MCP specification](https://modelcontextprotocol.io/specification/latest/basic/authorization), it acts as an OAuth 2.0 resource server that validates access tokens issued by Logto.
11+
- **MCP client**: A client used to initiate the authentication flow and test the integration. {<b>{props.isThirdParty ? 'The third-party AI agent will be used as the client in this guide.' : "We'll use VS Code (with built-in MCP support) as the client in this guide."}</b>}
12+
- **Logto**: Serves as the OpenID Connect provider (authorization server), manages user identities, and issues audience-bound JWT access tokens for your MCP server.
1313

1414
A non-normative sequence diagram illustrates the overall flow of the process:
1515

1616
<Mermaid value={`sequenceDiagram
17-
participant Client as MCP Client<br/>${props.isThirdParty ? '(third-party AI agent)' : '(MCP Inspector)'}
18-
participant Server as MCP Server
19-
participant Logto
20-
21-
Server->>Logto: Request OpenID Connect configuration
22-
Logto->>Server: Return configuration
23-
Note over Server: Cache the configuration
24-
Client->>Server: Request access to a tool
25-
Server->>Client: Not authenticated (401 Unauthorized)
26-
Client->>Server: Request OAuth 2.0 Authorization Server Metadata
27-
Note over Server: In this context, “OpenID Connect configuration” and<br/>“OAuth 2.0 Authorization Server Metadata”<br/>refer to the same thing.
28-
Server->>Client: Return OpenID Connect configuration retrieved from Logto
17+
participant Client as MCP Client<br/>${props.isThirdParty ? '(third-party AI agent)' : '(VS Code)'}
18+
participant Server as MCP Server<br/>(resource server)
19+
participant Logto as Logto<br/>(authorization server)
20+
21+
Client->>Server: MCP request (no token)
22+
Server->>Client: 401 Unauthorized (WWW-Authenticate)
23+
Client->>Server: Fetch protected resource metadata<br/>(/.well-known/oauth-protected-resource)
24+
Server->>Client: Return metadata with authorization server info
25+
Client->>Logto: Fetch authorization server metadata
26+
Logto->>Client: Return OpenID Connect configuration
2927
Client->>Logto: Redirect to Logto for authentication
3028
Logto->>Logto: User authenticates
31-
${props.isThirdParty ? 'Logto->>Logto: User authorizes (consents) scopes<br/>to the third-party app' : ''}
32-
Logto->>Client: Redirect back to MCP server with authorization code
33-
Client->>Logto: Request access token using authorization code
34-
Logto->>Client: Return access token
35-
Client->>Server: Request tool with access token
36-
Server->>Logto: Request user info using access token
37-
Logto->>Server: Return user info
29+
${props.isThirdParty ? 'Logto->>Logto: User authorizes (consents) scopes<br/>to the third-party AI agent' : ''}
30+
Logto->>Client: Redirect back with authorization code
31+
Client->>Logto: Exchange code for access token<br/>(with the resource parameter)
32+
Logto->>Client: Return access token (JWT, audience-bound)
33+
Client->>Server: MCP request with access token
34+
Server->>Server: Verify access token against Logto's JWKS<br/>(signature, issuer, audience, expiration)
3835
Server->>Client: Return tool response`}
3936

4037
/>
Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1-
import TabItem from '@theme/TabItem';
2-
import Tabs from '@theme/Tabs';
1+
:::info[Sample code]
2+
The complete, runnable sample code for this guide can be found in the [mcp-auth/js](https://github.com/mcp-auth/js/tree/master/packages/sample-servers) repository:
33

4-
<Tabs groupId="sdk">
5-
<TabItem value="python" label="Python">
4+
- [`whoami-express`](https://github.com/mcp-auth/js/tree/master/packages/sample-servers/src/whoami-express): the "whoami" server in this guide, on Node.js with Express.
5+
- [`whoami`](https://github.com/mcp-auth/js/tree/master/packages/sample-servers/src/whoami): the same server built fetch-native (web-standard `Request` / `Response` with [Hono](https://hono.dev)), deployable to Cloudflare Workers.
66

7-
The full MCP server code can be found in the [mcp-auth/python](https://github.com/mcp-auth/python) repository.
8-
9-
</TabItem>
10-
<TabItem value="node" label="Node.js">
11-
12-
The full MCP server code can be found in the [mcp-auth/js](https://github.com/mcp-auth/js) repository.
13-
14-
</TabItem>
15-
</Tabs>
7+
:::

0 commit comments

Comments
 (0)