aws-samples / aws-samples/agents4energy

OAuth credential flow for MCP servers

Open
#149 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
48
Forks
68
PR merge metrics
No merged PRs in 30d

Description

## Goal
Users can connect OAuth-protected MCP servers (e.g., GitHub, Google) via a PKCE popup. Per-user tokens are stored in DynamoDB and injected at invocation time.

## Acceptance criteria
- An MCP server with `oauthClientId` set shows a "Connect" button in the management UI
- Clicking "Connect" opens a PKCE popup via `web/lib/mcp-auth.ts`
- After authorization, tokens are saved to a `McpServerCredential` record (owner-only access)
- At chat invocation time, the user's access token is retrieved and injected as the `Authorization` header in the `remote_mcp` tool spec
- If the token is expired, the UI prompts re-authorization before invoking

## Files to modify
- `web/app/(with-auth)/agents/page.tsx` — add Connect button
- `web/lib/mcp-auth.ts` — ensure token storage writes to `McpServerCredential` via AppSync
- `web/lib/agentcore-transport.ts` — retrieve `McpServerCredential` at invoke time and inject token

## Dependencies
- Issue #148 (MCP CRUD UI must exist first)

---
*Imported from `waltmayf/agentcore-amplify-fullstack`#35 — originally filed by @waltmayf on 2026-07-02. Migrated to open-source repo; cross-references updated post-import.*

Contributor guide

Open the contributing guide

Research direction

Read issue #148 first, then inspect web/app/(with-auth)/agents/page.tsx, web/lib/mcp-auth.ts, and web/lib/agentcore-transport.ts. Trace the existing AppSync and MCP invocation paths before implementing the Connect flow and credential lookup. Done means OAuth-protected servers can authorize, store owner-only credentials, inject the user's token, and prompt again when it expires.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
authentication, backend-api-design, frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.