Skip to content

Commit 6ab912f

Browse files
committed
Better MCP oauth
1 parent 2605373 commit 6ab912f

36 files changed

+2343
-1863
lines changed

docs/mcp/connecting.md

Lines changed: 157 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,25 @@ id: connecting
33
title: Connecting
44
---
55

6-
The TanStack MCP Server is available at `https://tanstack.com/api/mcp` and uses the Streamable HTTP transport. Authentication via API key is required.
6+
The TanStack MCP Server is available at `https://tanstack.com/api/mcp` and uses the Streamable HTTP transport.
77

8-
## Getting an API Key
8+
## Authentication Options
99

10-
Before connecting, you'll need to create an API key:
10+
There are two ways to authenticate with the TanStack MCP server:
11+
12+
### OAuth (Recommended)
13+
14+
MCP clients that support OAuth can authenticate automatically. Just use the server URL and your client will open a browser window to authorize access:
15+
16+
```
17+
https://tanstack.com/api/mcp
18+
```
19+
20+
No API key needed. Your client handles the OAuth flow automatically.
21+
22+
### API Keys
23+
24+
For clients that don't support OAuth, or if you prefer manual key management:
1125

1226
1. [Sign in to your TanStack account](/login)
1327
2. Go to [API Keys](/account/api-keys)
@@ -17,36 +31,78 @@ Before connecting, you'll need to create an API key:
1731
> [!NOTE]
1832
> Replace `YOUR_API_KEY` in the examples below with your actual API key.
1933
20-
## OpenCode
34+
## Claude Desktop
2135

22-
Add to your OpenCode MCP configuration in `~/.config/opencode/config.json`:
36+
Claude Desktop supports OAuth authentication. Add to your config:
37+
38+
**macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
39+
**Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
2340

2441
```json
2542
{
26-
"mcp": {
27-
"servers": {
28-
"tanstack": {
29-
"type": "remote",
30-
"url": "https://tanstack.com/api/mcp",
31-
"headers": {
32-
"Authorization": "Bearer YOUR_API_KEY"
33-
}
43+
"mcpServers": {
44+
"tanstack": {
45+
"url": "https://tanstack.com/api/mcp"
46+
}
47+
}
48+
}
49+
```
50+
51+
Restart Claude Desktop. On first use, a browser window will open to authorize access.
52+
53+
<details>
54+
<summary>Using an API key instead</summary>
55+
56+
```json
57+
{
58+
"mcpServers": {
59+
"tanstack": {
60+
"command": "npx",
61+
"args": ["mcp-remote", "https://tanstack.com/api/mcp"],
62+
"env": {
63+
"MCP_HEADERS": "Authorization: Bearer YOUR_API_KEY"
3464
}
3565
}
3666
}
3767
}
3868
```
3969

70+
</details>
71+
4072
## Claude Code
4173

74+
```bash
75+
claude mcp add tanstack https://tanstack.com/api/mcp
76+
```
77+
78+
On first use, a browser window will open to authorize access.
79+
80+
<details>
81+
<summary>Using an API key instead</summary>
82+
4283
```bash
4384
claude mcp add --transport http tanstack https://tanstack.com/api/mcp --header "Authorization: Bearer YOUR_API_KEY"
4485
```
4586

87+
</details>
88+
4689
## Cursor
4790

4891
Add to your Cursor MCP configuration:
4992

93+
```json
94+
{
95+
"mcpServers": {
96+
"tanstack": {
97+
"url": "https://tanstack.com/api/mcp"
98+
}
99+
}
100+
}
101+
```
102+
103+
<details>
104+
<summary>Using an API key instead</summary>
105+
50106
```json
51107
{
52108
"mcpServers": {
@@ -61,10 +117,25 @@ Add to your Cursor MCP configuration:
61117
}
62118
```
63119

120+
</details>
121+
64122
## VS Code
65123

66124
Add to your VS Code settings or `.vscode/mcp.json`:
67125

126+
```json
127+
{
128+
"servers": {
129+
"tanstack": {
130+
"url": "https://tanstack.com/api/mcp"
131+
}
132+
}
133+
}
134+
```
135+
136+
<details>
137+
<summary>Using an API key instead</summary>
138+
68139
```json
69140
{
70141
"servers": {
@@ -79,33 +150,71 @@ Add to your VS Code settings or `.vscode/mcp.json`:
79150
}
80151
```
81152

82-
## Claude Desktop
153+
</details>
83154

84-
Add the following to your Claude Desktop configuration file:
155+
## OpenCode
85156

86-
**macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
87-
**Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
157+
Add to your OpenCode MCP configuration in `~/.config/opencode/config.json`:
88158

89159
```json
90160
{
91-
"mcpServers": {
92-
"tanstack": {
93-
"command": "npx",
94-
"args": ["mcp-remote", "https://tanstack.com/api/mcp"],
95-
"env": {
96-
"MCP_HEADERS": "Authorization: Bearer YOUR_API_KEY"
161+
"mcp": {
162+
"servers": {
163+
"tanstack": {
164+
"type": "remote",
165+
"url": "https://tanstack.com/api/mcp"
166+
}
167+
}
168+
}
169+
}
170+
```
171+
172+
After adding the config, run the auth flow manually the first time:
173+
174+
```bash
175+
npx mcp-remote auth https://tanstack.com/api/mcp
176+
```
177+
178+
This opens a browser to authorize access. After that, OpenCode will connect automatically.
179+
180+
<details>
181+
<summary>Using an API key instead</summary>
182+
183+
```json
184+
{
185+
"mcp": {
186+
"servers": {
187+
"tanstack": {
188+
"type": "remote",
189+
"url": "https://tanstack.com/api/mcp",
190+
"headers": {
191+
"Authorization": "Bearer YOUR_API_KEY"
192+
}
97193
}
98194
}
99195
}
100196
}
101197
```
102198

103-
Restart Claude Desktop after updating the configuration.
199+
</details>
104200

105201
## Windsurf
106202

107203
Add to your Windsurf MCP configuration:
108204

205+
```json
206+
{
207+
"mcpServers": {
208+
"tanstack": {
209+
"serverUrl": "https://tanstack.com/api/mcp"
210+
}
211+
}
212+
}
213+
```
214+
215+
<details>
216+
<summary>Using an API key instead</summary>
217+
109218
```json
110219
{
111220
"mcpServers": {
@@ -119,24 +228,46 @@ Add to your Windsurf MCP configuration:
119228
}
120229
```
121230

231+
</details>
232+
122233
## MCP Inspector
123234

124235
Use the MCP Inspector to test the server interactively:
125236

237+
```bash
238+
npx @modelcontextprotocol/inspector https://tanstack.com/api/mcp
239+
```
240+
241+
<details>
242+
<summary>Using an API key instead</summary>
243+
126244
```bash
127245
npx @modelcontextprotocol/inspector https://tanstack.com/api/mcp --header "Authorization: Bearer YOUR_API_KEY"
128246
```
129247

248+
</details>
249+
130250
## Custom Integration
131251

132252
For custom integrations, the server accepts standard MCP requests via HTTP:
133253

134254
- **Endpoint:** `https://tanstack.com/api/mcp`
135255
- **Transport:** Streamable HTTP (stateless)
136256
- **Methods:** POST (for requests), GET (for server-sent events), DELETE (for session cleanup)
137-
- **Authentication:** Bearer token via Authorization header
257+
- **Authentication:** OAuth 2.1 (recommended) or Bearer token via Authorization header
258+
259+
### OAuth 2.1 Flow
260+
261+
The server supports OAuth 2.1 with PKCE for secure authentication:
262+
263+
1. Discover endpoints via `/.well-known/oauth-authorization-server`
264+
2. Redirect user to `/oauth/authorize` with PKCE challenge
265+
3. Exchange authorization code at `/oauth/token`
266+
4. Use the access token as a Bearer token
267+
268+
### API Key Authentication
138269

139-
Example request using curl:
270+
Example request using curl with an API key:
140271

141272
```bash
142273
curl -X POST https://tanstack.com/api/mcp \

docs/mcp/overview.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,14 @@ AI assistants are trained on snapshots of documentation that become stale over t
1515

1616
## Quick Start
1717

18-
Copy and paste the following instructions to your AI agent:
19-
20-
> [!NOTE]
21-
> Replace `YOUR_API_KEY` with an API key from [tanstack.com/account/api-keys](/account/api-keys)
18+
Most MCP clients support OAuth authentication. Just add the server URL:
2219

2320
```
24-
Connect to the TanStack MCP server with these settings:
25-
26-
URL: https://tanstack.com/api/mcp
27-
Transport: Streamable HTTP
28-
Authorization Header: Bearer YOUR_API_KEY
21+
https://tanstack.com/api/mcp
2922
```
3023

24+
Your client will open a browser window to authorize access on first use. No API key needed.
25+
3126
See [Connecting](./connecting) for client-specific setup instructions.
3227

3328
## Available Tools

0 commit comments

Comments
 (0)