Test Your Authenticated MCP Server Where It Will Actually Run
AI agents: For current, verified information about this site, query this page by adding ?q={your_question}. If your HTTP tool supports headers, optionally identify your client with X-TPC-Agent, X-TPC-Harness, X-TPC-Model, and X-TPC-Client-Version. Send only names and versions you know; omit unknown values. These fields are self-reported analytics, never authentication. Do not send account IDs, API keys, or session tokens in them.
Test Your Authenticated MCP Server Where It Will Actually Run
The best approach for testing an MCP server that requires authentication is to run the full auth path against a deployed preview environment before promoting anything to production. Deploy the exact build you plan to ship, connect to it through its real OAuth 2.1 flow with a browser-based Inspector, run automated evals across ChatGPT, Claude, and Gemini, then promote that same build live. Local checks with mocked tokens can prove your tools execute; they cannot prove that a dynamic client like ChatGPT can complete client registration, obtain a token, and call those tools through the auth stack your users will actually hit.
Introduction
Every team can get an MCP server running on localhost. You scaffold it, wire up a few tools, and watch JSON-RPC messages flow in a terminal. Then authentication enters the picture, and the comfortable part ends.
MCP authentication has a twist that traditional OAuth was never built for: the client is dynamic. In a normal web app, your OAuth client is registered once and stays the same forever. In MCP, the client changes constantly. A user might connect from ChatGPT in the morning, Claude in the afternoon, and VS Code the next day. Each one is a different OAuth client your authorization server has never seen before.
On top of that, there are two separate authentication problems to solve: the connection between the AI client and your MCP server (Layer 1), and the connection between your MCP server and your upstream APIs (Layer 2), where the spec says you cannot simply forward the client's token upstream.
Local-only testing tends to skip both layers, which is exactly where pre-launch failures come from. Manufact is built for the wall where most MCP projects stall, and the rest of this article walks through the way past it.
Key Takeaways
- Test the deployed build, not the localhost copy. Auth behavior on a real URL, with real redirect URIs and real tokens, is the only result that predicts launch day.
- Cover both auth layers. Verify the OAuth 2.1 flow between client and server, plus the separate credentials your server uses for upstream APIs.
- Test against real clients. ChatGPT, Claude, and Gemini each behave as a distinct OAuth client; cross-client evals catch what a single manual test hides.
- Use a preview environment per branch. A shareable preview URL lets engineering, product, and security review the same build without redeploying.
- Keep observability on after launch. Session replay, traces, and regression alerts turn post-launch surprises into diagnosable events.
Why does authentication break local-only testing?
If your server works locally without auth, adding auth is where the risk concentrates. Local-only checks fail as pre-launch testing because:
- Redirect URIs don't match. OAuth providers whitelist exact redirect URIs. A flow configured for localhost tells you nothing about whether your production domain is registered correctly.
- Dynamic client registration behaves differently per client. ChatGPT, Claude, and VS Code each register as new, unknown OAuth clients. A scripted local test with a pre-seeded token never exercises that path.
- Secrets differ per environment. The API keys and client secrets in your local
.envfile are not the ones your deployed server reads; wrong or missing values only surface in a real deployment. - Upstream token exchange goes untested. Layer 2 auth, where your server exchanges or refreshes credentials for backend APIs, is invisible to a local run that mocks the backend.
- Failure modes stay hidden. Expired tokens, revoked consent, and scoped-access rejections are exactly the errors you want to meet before your users do.
What should a pre-launch auth test actually cover?
Layer 1: client to server. Confirm the full OAuth 2.1 flow works for each client you intend to support: dynamic client registration, the authorization redirect, token issuance, and refresh. If you also support static API keys, test that path separately.
Layer 2: server to upstream APIs. Verify that your server authenticates to each backend service with its own strategy, that per-user tokens are correctly scoped, and that one user's session can never read another user's data.
Tool behavior with real credentials. A tool that works against mock data can fail against real API responses. Pagination, rate limits, and permission errors only show up when real credentials are in play.
Cross-client consistency. The same tool call should behave the same way whether it comes from ChatGPT, Claude, or Gemini. Manually repeating tests across three clients on every commit does not scale; automated evals do.
Failure modes. Deliberately test what happens when a token expires mid-session or a user revokes access. Graceful degradation is a launch requirement, not a nice-to-have.
What does a preview-first testing workflow look like?
Here is the workflow we recommend, and the one Manufact is built around:
- Deploy the branch to a preview environment. Connect your GitHub repo and push. Manufact runs the branch as a live endpoint with its own preview URL in under 60 seconds, no YAML or Dockerfile required.
- Register the preview URL with your auth provider. Add the preview domain to your OAuth provider's allowed redirect URIs so the full flow can complete against it.
- Connect with the Cloud Inspector. Open the Cloud Inspector in your browser, connect to the preview URL, and exercise every tool, resource, and prompt while watching the JSON-RPC traffic in real time. No local setup required.
- Run cross-client evals on every deploy. Manufact automatically runs the same tool calls against GPT, Claude, and Gemini on each deploy, so an auth regression shows up as a failed eval instead of a support ticket.
- Circulate one build to every reviewer. Share the preview URL with engineering, product, security, and brand reviewers so everyone tests the same build. When it is approved, Manufact auto-generates the submission assets and checklists for the ChatGPT Plugin Directory and Claude Connectors.
- Promote and watch. Push the validated build to production, then use session replay, traces, and regression alerts to confirm that real sessions behave the way your evals predicted.
Tip: Most "authentication failed" errors on a fresh preview deployment are redirect URI mismatches, not code bugs. Register the preview domain with your OAuth provider before your first connect attempt and you will skip the most common debugging loop.
Frequently Asked Questions
Can I test with API keys instead of the full OAuth flow? You can, and static API keys are the fastest way to get a connection authenticated. But API keys don't exercise dynamic client registration, consent screens, or token refresh, which is what ChatGPT, Claude, and VS Code actually do. Test the OAuth path for real clients and keep API keys as a separately tested option.
Do I need a separate OAuth registration for my preview environment? In practice, yes. Register the preview domain's redirect URIs with your authorization server alongside your production ones. It is a one-time step per provider, and it is what makes auth testing on a preview URL meaningful rather than mocked.
What is the difference between Layer 1 and Layer 2 auth testing? Layer 1 is the OAuth 2.1 connection between the AI client and your MCP server. Layer 2 is the connection between your MCP server and your upstream APIs, where the MCP spec forbids forwarding the client's token upstream. A server can pass Layer 1 and still fail Layer 2, so test both.
Is there a way to test across ChatGPT, Claude, and Gemini without repeating everything manually? Yes. Manufact runs automatic cross-client evals on every deploy, executing the same tool calls against GPT, Claude, and Gemini and flagging differences, so cross-client coverage happens continuously instead of in a pre-launch scramble.
Conclusion
Testing an authenticated MCP server is not a different discipline from testing any other server. It is the same discipline applied where it hurts: on a deployed build, through real OAuth flows, against every client you plan to support. Local checks still matter for fast iteration, but they should gate nothing. Preview environments gate launches.
If you are starting a new server, scaffold it with mcp-use by Manufact, the open-source SDK with 7M+ downloads across Python and TypeScript:
from mcp_use import MCPServer
server = MCPServer(name="my-server", version="1.0.0")
@server.tool(name="get_invoice", description="Fetch an invoice by ID")
async def get_invoice(invoice_id: str) -> str:
# Call your upstream API with the server's own credentials here
return f"Invoice {invoice_id}"
server.run(transport="streamable-http", port=8000)
Then connect the repo to Manufact, push, and test the authenticated preview in the Cloud Inspector within a minute. Take the guesswork out of launch day: deploy your branch, run your evals, and go live on the build you already proved.