I already had Google Analytics and Search Console connected to Codex on my Mac. For Design by HL, I wanted to ask the same questions in ChatGPT on the web, including when the Mac was off. I put two read-only reporting tools on an always-on host and connected them as a personal ChatGPT plugin.
The reporting workflow is simple. I select the plugin and ask for a comparison across the main site and the dashboard. The server handles sign-in, selects the appropriate Google properties and returns the report rows. The same approach works for other APIs you control.
Compare main-site and dashboard GA4 sessions for the last complete week
with the week before. Then compare finalized Search Console clicks and
impressions. Show the exact date ranges used for each source.
This guide starts with a small local server and takes it through to a working connection in web ChatGPT. If you’re setting up local Codex reporting, the companion guides cover those connections. Google Analytics MCP · Google Search Console MCP
Start with a tool that returns a fixed result
MCP, or Model Context Protocol, gives ChatGPT a way to discover a server’s tools and call them with structured inputs. You need Python, an HTTPS host that can keep your process running, and a ChatGPT workspace that allows custom MCP servers. Start on your own computer with a function that returns a known value. This lets you test tool discovery and execution before adding Google credentials. OpenAI custom MCP server setup
Save this as server.py.
from fastmcp import FastMCP
mcp = FastMCP("Reporting demo")
@mcp.tool(annotations={"readOnlyHint": True})
def report_status() -> dict[str, str]:
"""Check that the demo server is responding."""
return {"status": "ready"}
if __name__ == "__main__":
mcp.run(transport="http", host="127.0.0.1", port=8000)
python3 -m venv .venv
.venv/bin/python -m pip install 'fastmcp==4.1.8'
.venv/bin/python server.py
In a second terminal in the same directory, call the tool from a FastMCP client.
.venv/bin/python - <<'PY'
import asyncio
from fastmcp import Client
async def main():
async with Client("http://127.0.0.1:8000/mcp") as client:
result = await client.call_tool("report_status", {})
print(result.data)
asyncio.run(main())
PY
You should see {'status': 'ready'}. The demo binds to your computer’s loopback address and uses fixed sample data. Add authentication before exposing reporting tools over a network. FastMCP HTTP server setup
Turn the Google reports into two tools
For Design by HL, I used two site choices, main and dashboard. Each maps to a separate GA4 property. Both share a Search Console property, so the server uses a page filter to include the dashboard for one choice and exclude it for the other. The model can ask for a date range and breakdown. The server chooses the property, API endpoint and filters.
| Tool | Inputs | Useful output |
|---|---|---|
| GA4 report | Site, start date, end date, breakdown and row limit | Sessions, users, views and engaged sessions |
| Search Console performance | Site, start date, end date, breakdown and row limit | Clicks, impressions, click-through rate and position |
Use the GA4 Data API’s runReport method and Search Console’s searchAnalytics.query. Validate the dates, allowed breakdowns and row limits in your server code. Use Search Console’s dataState: final for settled comparisons, and return the dates and time zone with the data. GA4 dates follow the property’s time zone, while Search Console dates follow Pacific Time. An empty response for a recent date can mean the data is still processing. GA4 report method · Search Console query method
readOnlyHint tells ChatGPT how to present a tool. Enforce the access rules in the server with read-only OAuth scopes, fixed report methods and the site mapping. A Google account can have access to more properties than you intend to expose through the plugin. The server’s property allowlist keeps those other properties outside the tool’s inputs.
Configure Google OAuth and the ChatGPT connection
Enable the Google Analytics Data API and Search Console API in Google Cloud. Create a Web application OAuth client for the hosted service and register your server’s exact callback, such as https://mcp.example.com/auth/callback. Use the first two scopes below to identify the signed-in account and the last two to read reports. Google web OAuth · Google OAuth scopes
openid
https://www.googleapis.com/auth/userinfo.email
https://www.googleapis.com/auth/analytics.readonly
https://www.googleapis.com/auth/webmasters.readonly
There are two OAuth relationships. Google sends the sign-in result back to the MCP server. The MCP server then authorizes ChatGPT to call its tools. Use an OAuth implementation such as FastMCP OAuth Proxy to handle this flow. Configure OAuth discovery, the S256 PKCE code challenge, and tokens bound to the /mcp resource. Allowlist the exact ChatGPT redirect URL displayed in its connection settings. That callback belongs in the MCP OAuth configuration. FastMCP OAuth Proxy · ChatGPT MCP authentication
In my setup, the server checks the verified owner account before issuing access and again when the plugin calls a tool. I keep the Google client secret and signing key server-side and preserve encrypted OAuth state outside the web root. One sign-in initially failed because Google returned both email and the full userinfo.email scope. Normalizing that alias let the strict scope check accept the intended permission set.
For an external Google OAuth app, Testing mode applies a seven-day authorization limit to these reporting scopes. Use In production for ongoing use. Google’s verification review is a separate step and has a personal-use exception. The server’s verified-owner check controls who can use the reporting endpoint. Document how Google data is used, including what the MCP sends back to ChatGPT. Google OAuth publishing status · Personal-use exception · Google API data-use policy
Host the MCP on a dedicated HTTPS subdomain
Run the authenticated server on a host that can keep the Python process available. Point a subdomain such as mcp.example.com at the app and configure the public HTTPS origin explicitly. The example endpoint is https://mcp.example.com/mcp using Streamable HTTP. The host runs the service independently of your computer.
On Veebimajutus, enable the subdomain’s certificate and HTTPS redirect, then use PM2 to run the app from its virtual environment. Bind to the provider’s ELKDATA_APP_IP on an unused port. In Portide suunamine, forward the entire MCP subdomain to that port. This makes the discovery, authorization and callback routes reachable alongside /mcp. Save the PM2 process list after the app is online so the host can restore it after maintenance. Veebimajutus port forwarding · Veebimajutus PM2 guide
Check the unauthenticated endpoint before you connect it to ChatGPT.
curl -i 'https://mcp.example.com/mcp' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
--data '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
Expect 401 Unauthorized with a WWW-Authenticate header pointing to the protected-resource metadata. Follow that discovery link and check that the resource and authorization server URLs match your public deployment. A 502 at this point usually sends me back to the process status, the bind address and the proxy port. OpenAI connection tests
Install the personal plugin in web ChatGPT
- Open Plugins in web ChatGPT and choose Add custom MCP server from the plus menu.
- Enter a name and the full HTTPS
/mcpURL. Choose OAuth. Select CIMD if your authorization server advertises Client ID Metadata Documents and the connection settings offer it. - Review the issuer, callback and scopes. With CIMD, ChatGPT uses a client metadata URL and the Google client secret stays on your server.
- Choose Create as a plugin, install it from your personal plugins, and sign in with the Google account your server allows.
- In a new chat, select the plugin with
@and request one report for a known date. OpenAI custom MCP server setup
Check both reporting tools before using the results
My first web test made four calls, one GA4 report and one Search Console report for each site choice. All four returned data. Comparing the same dates in the Google interfaces is a quick way to catch a wrong property, a dashboard filter that includes the main site, or a date range that includes unsettled Search Console data.
Test one invalid site alias and one account outside the allowlist, and make sure requests without a token still return 401. Restart the service and confirm the existing plugin connection can read a report afterward. If you change a tool’s name or inputs, refresh its metadata in the ChatGPT connection settings before testing again. OpenAI plugin testing guide
Once the connection works, the reporting question matters more than the setup. Start with one complete week and the week before, state the exact dates, and ask which pages explain the biggest change. How I compare GA4 and Search Console data
Building a feature for your web application?
The useful part of a technical approach is how it works for your users. I build interfaces, connect them to existing APIs and help product teams improve features, including loading, empty and error states.
Explore frontend development for your application
Related work and examples
Dashboard
A COVID data explorer grew into a personal dashboard and a collection of everyday web tools. A long-running React project where I learned to connect interfaces, interactive charts and real data.