You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This hands-on guide demonstrates how to secure your Neo.mjs MCP servers (Knowledge Base or Memory Core) using Google OAuth 2.1. This allows you to restrict access to your AI tools using your organization's Google workspace.
4
+
5
+
## Prerequisites
6
+
7
+
1. A Google Cloud Platform (GCP) project.
8
+
2. The Neo.mjs project cloned and initialized.
9
+
3. The MCP server deployed to a public URL (or using a tunnel like `ngrok` for local testing).
10
+
11
+
---
12
+
13
+
## Step 1: Configure Google Cloud Console
14
+
15
+
1. Go to the [GCP APIs & Services > Credentials](https://console.cloud.google.com/apis/credentials) page.
3. Select **Web application** as the application type.
18
+
4.**Authorized JavaScript origins:** Add the public URL of your MCP server (e.g., `https://mcp.yourdomain.com`).
19
+
5.**Authorized redirect URIs:** Since the MCP server acts as a **Protected Resource**, it doesn't handle the user login redirect itself. However, your **MCP Client** (e.g., VS Code or a custom UI) will need a redirect URI.
20
+
6. Click **Create** and note your **Client ID** and **Client Secret**.
21
+
22
+
---
23
+
24
+
## Step 2: Configure the MCP Server
25
+
26
+
Update your `.env` file or IaC environment variables.
27
+
28
+
### Using OIDC Discovery (Recommended)
29
+
Google provides a standard OIDC discovery endpoint. This is the easiest way to configure the server.
Ensure `HOST` is set correctly. If your server is behind a load balancer with SSL termination, ensure `HOST` does not include the protocol unless you want to force one. The server will default to `https` for any host other than `localhost`.
44
+
45
+
---
46
+
47
+
## Step 3: Technical Nuances
48
+
49
+
### Token Introspection
50
+
Unlike Keycloak, Google does not strictly adhere to the RFC 7662 introspection spec for all token types in the same way. However, for **OpenID Connect**, the MCP SDK handles the validation of the Bearer token.
51
+
52
+
### Audience (aud) Validation
53
+
Google ID Tokens include the `aud` field, which matches your `OAUTH_CLIENT_ID`. The Neo.mjs MCP server will validate that the incoming token's audience is authorized to access the resource.
54
+
55
+
> **Note:** In complex scenarios where the client and server use different GCP projects, you may need to configure additional audience mappings in your GCP project.
56
+
57
+
---
58
+
59
+
## Step 4: Testing with a Client
60
+
61
+
When connecting an MCP client (like VS Code) to your server:
62
+
63
+
1. The client will hit `https://mcp.yourdomain.com/.well-known/oauth-protected-resource`.
64
+
2. It will discover that the server requires authorization from `https://accounts.google.com`.
65
+
3. The client will initiate the OAuth flow with Google.
66
+
4. Once authorized, the client will send requests with the header:
67
+
`Authorization: Bearer <google_access_token>`
68
+
69
+
---
70
+
71
+
## Troubleshooting
72
+
73
+
### 401 Unauthorized
74
+
Verify that the `OAUTH_CLIENT_ID` in your server config matches the one used by the client to obtain the token.
75
+
76
+
### OIDC Discovery Failure
77
+
If the server logs `Failed to fetch OIDC discovery document`, ensure the server has outbound internet access to reach `https://accounts.google.com/.well-known/openid-configuration`.
0 commit comments