22
33This guide shows how to test OAuth authentication with Basic Memory MCP server, including how to connect from Claude.ai.
44
5+ ## MCP Inspector Testing
6+
7+ To test with MCP Inspector when OAuth is enabled:
8+
9+ 1 . ** Start the server with OAuth** :
10+ ``` bash
11+ FASTMCP_AUTH_ENABLED=true basic-memory mcp --transport streamable-http
12+ ```
13+
14+ 2 . ** Register a client** (in another terminal):
15+ ``` bash
16+ basic-memory auth register-client --client-id=test-client
17+ # Save the client_secret that's generated!
18+ ```
19+
20+ 3 . ** Get an access token** :
21+ ``` bash
22+ # Test the flow to get a token
23+ basic-memory auth test-auth
24+ # Look for "Access token: ..." in the output
25+ ```
26+
27+ 4 . ** Use token in MCP Inspector** :
28+ - Header Name: ` Authorization `
29+ - Bearer Token: ` <paste the access token from step 3> `
30+
31+ Or manually get a token:
32+ ``` bash
33+ # Get authorization code
34+ curl " http://localhost:8000/auth/authorize?client_id=test-client&redirect_uri=http://localhost:3000/callback&response_type=code&code_challenge=test"
35+
36+ # Exchange for token (use code from redirect URL)
37+ curl -X POST http://localhost:8000/auth/token \
38+ -H " Content-Type: application/x-www-form-urlencoded" \
39+ -d " grant_type=authorization_code&code=YOUR_CODE&client_id=test-client&client_secret=YOUR_SECRET&code_verifier=test"
40+ ```
41+
542## Local Testing with Built-in Provider
643
7441 . ** Create ` .env ` file** :
@@ -21,7 +58,7 @@ This guide shows how to test OAuth authentication with Basic Memory MCP server,
2158 basic-memory mcp --transport streamable-http
2259
2360 # Or directly
24- FASTMCP_AUTH_ENABLED=true basic-memory mcp --transport streamable-http
61+
2562 ```
2663
27644 . ** Register a client** :
@@ -57,15 +94,47 @@ This guide shows how to test OAuth authentication with Basic Memory MCP server,
5794
5895When OAuth is enabled, these endpoints are available:
5996
60- - ` GET /authorize ` - OAuth authorization endpoint
61- - ` POST /token ` - Token exchange endpoint
97+ - ` GET /auth/ authorize ` - OAuth authorization endpoint
98+ - ` POST /auth/ token ` - Token exchange endpoint
6299- ` GET /mcp ` - Protected MCP endpoint (requires Bearer token)
63100
101+ ## Testing with MCP Inspector
102+
103+ ** Note** : The OAuth2 flow typically requires browser interaction. With MCP Inspector, you can use bearer token authentication directly.
104+
105+ ### Bearer Token Approach
106+
107+ 1 . Run the test-auth command to get tokens:
108+ ``` bash
109+ basic-memory auth test-auth
110+ ```
111+ This will output an access token that you can copy.
112+
113+ 2 . In MCP Inspector:
114+ - Server URL: ` http://localhost:8000/mcp `
115+ - Transport: ` streamable-http `
116+ - Add custom headers:
117+ ```
118+ Authorization: Bearer YOUR_ACCESS_TOKEN
119+ ```
120+
121+ ### Full OAuth Flow Testing
122+
123+ If you want to test the full OAuth flow:
124+
125+ 1. Register a client:
126+ ```bash
127+ basic-memory auth register-client
128+ ```
129+ Copy the returned ` client_id ` and ` client_secret ` .
130+
131+ 2 . Follow the OAuth flow described below with the correct callback URL (` http://localhost:8000/auth/callback ` ).
132+
64133## Testing with cURL
65134
661351 . ** Get authorization code** :
67136 ``` bash
68- curl " http://localhost:8000/authorize?client_id=YOUR_CLIENT_ID&redirect_uri=http://localhost:3000 /callback&response_type=code&code_challenge=test"
137+ curl " http://localhost:8000/authorize?client_id=YOUR_CLIENT_ID&redirect_uri=http://localhost:8000/auth /callback&response_type=code&code_challenge=test"
69138 ```
70139
711402 . ** Exchange for token** :
@@ -99,7 +168,7 @@ async def test_oauth():
99168 " http://localhost:8000/authorize" ,
100169 params = {
101170 " client_id" : client_id,
102- " redirect_uri" : " http://localhost:3000 /callback" ,
171+ " redirect_uri" : " http://localhost:8000/auth /callback" ,
103172 " response_type" : " code" ,
104173 " code_challenge" : " test-challenge" ,
105174 " code_challenge_method" : " S256" ,
0 commit comments