AWS Builder Center
Connecting Kiro to Google Stitch with MCP: Lessons from a Real Setup

Connecting Kiro to Google Stitch with MCP: Lessons from a Real Setup

How I gave my Kiro agent direct access to my UI designs, and the seven errors I had to decode along the way.

DevOps Engineer | AI/ML Engineer
Agentic IDEs get a lot more useful when the agent can reach the systems your work actually lives in. For me, that meant my designs.

I'm was building a mobile app that helps people build a daily Quran-learning habit through short lessons. The backend is Django on AWS, the mobile app is Flutter, and the code lives in Kiro. The UI lives in Google Stitch containing ten mobile screens and a complete design system.

I wanted my Kiro agent to read those designs directly so it could map screens to routes and turn design tokens into a Flutter theme without me having to copy hex codes by hand.
Stitch provides a remote Model Context Protocol (MCP) server, and Kiro supports remote MCP servers. However, Google Stitch doesn't provide a ready-to-use MCP configuration for Kiro that I can simply copy and paste into Kiro's MCP configuration. That's where the problem lies.

This article walks through the setup in the order I actually hit problems, what each error really meant, and the configuration I run today. If you connect Kiro to any remote, OAuth-protected MCP server, most of these lessons will carry over.



What you'll build

  • Kiro connected to the remote Stitch MCP server at  https://stitch.googleapis.com/mcp 
  • An agent that can call Stitch tools such as  list_projects ,  list_screens ,  get_screen ,  download_file , and  generate_screen_from_text 
  • A configuration with no secrets committed to source control
  • A repeatable way to refresh short-lived credentials

Prerequisites

  • Kiro (IDE or CLI)
  • A Google account with at least one Stitch project
  • A Google Cloud project where you can enable APIs
  • The  gcloud  CLI



Remote MCP servers in Kiro

Most MCP servers run locally. Kiro starts a process and talks to it over standard input and output. Stitch is a remote server. Kiro talks to it over HTTPS, so the configuration has a  url  instead of a  command , and every request carries credentials in HTTP headers.
Kiro reads MCP configuration from two locations:
Scope
Path
Notes
Workspace
 .kiro/settings/mcp.json 
Project-specific; takes precedence
User
 ~/.kiro/settings/mcp.json 
Applies to every workspace
Kiro expands environment variables in header values using  ${VAR_NAME} . That lets you keep secrets out of the file, and it turns out to be central to getting this right.



Start with an API key

Stitch supports two authentication methods: API keys, created in Stitch Settings, and OAuth through  gcloud . API keys are the documented easy path, so I started there.
{
"mcpServers": {
"stitch": {
"url": "https://stitch.googleapis.com/mcp",
"headers": {
"Accept": "application/json",
"X-Goog-Api-Key": "${STITCH_API_KEY}"
},
"timeout": 120000
}
}
}
The Stitch documentation shows the key pasted inline. I used an environment variable instead, so the file is safe to share and review.

Validate the config after every edit

After a few edits, my file contained one complete JSON object followed by a stray fragment and an extra brace. Kiro didn't raise an obvious error. The server simply didn't load.
python3 -m json.tool .kiro/settings/mcp.json > /dev/null && echo "valid"
The validator reported  Extra data: line 16 column 5 . That's the parser telling you the object ended and more text followed. Make this check a habit.

 /mcp  shows live state; other views can lag

With valid JSON, I opened a session and checked the tool list. I saw only the built-in tools. Then I checked  /mcp :
filesystem ● running 14 tools
stitch ● running 16 tools
MCP servers connect asynchronously at session start. A remote handshake or a first-time package download can take several seconds, and the tool list I checked was captured before the servers finished connecting.  /mcp  reports current connection state, so trust it first.

Connected doesn't mean authorized

The server was running and its tools were listed, yet nothing returned useful data. To see the raw responses, I called the endpoint directly. A remote MCP server speaks JSON-RPC over HTTPS, so  curl  makes a good debugger:
# Handshake
curl -sS -X POST https://stitch.googleapis.com/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "X-Goog-Api-Key: $STITCH_API_KEY" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"probe","version":"0.1"}}}'

# A real tool call
curl -sS -X POST https://stitch.googleapis.com/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "X-Goog-Api-Key: $STITCH_API_KEY" \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"list_projects","arguments":{}}}'
The handshake returned HTTP 200, and  tools/list  returned all 16 tools. The  list_projects  call returned:
Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential.
I got the same result with the key as a query parameter and with a different tool. In my setup, the API key authenticated the connection but not access to project data. The Stitch documentation says API keys are supported, so your experience may differ by account or project. If you see this exact message, though, move to OAuth rather than troubleshooting the key.
Takeaway: a healthy connection status only proves the handshake worked. Test with a tool call that reads real data.



Switch to OAuth with Application Default Credentials

The OAuth path uses your Google identity through Application Default Credentials (ADC).
gcloud auth login
gcloud auth application-default login

PROJECT_ID="your-project-id"
gcloud config set project "$PROJECT_ID"

gcloud projects add-iam-policy-binding "$PROJECT_ID" \
--member="user:$(gcloud config get-value account)" \
--role="roles/serviceusage.serviceUsageConsumer" \
--condition=None
The headers change to a Bearer token plus the project used for quota:
"headers": {
"Accept": "application/json",
"Authorization": "Bearer ${STITCH_ACCESS_TOKEN}",
"X-Goog-User-Project": "${GOOGLE_CLOUD_PROJECT}"
}
You get the token with:
gcloud auth application-default print-access-token
The credential error went away, and a new one appeared.

Confirm the API is actually enabled

Stitch API has not been used in project  your-project-id  before or it is disabled.
The Stitch documentation suggests  gcloud beta services mcp enable stitch.googleapis.com . In my case, the API still didn't show as enabled afterwards. The standard command worked:
gcloud services enable stitch.googleapis.com --project="$PROJECT_ID"
gcloud services list --enabled --project="$PROJECT_ID" | grep -i stitch
After a short propagation delay,  list_projects  returned my projects.

Set a quota project, and download through the tool

Listing projects and screens worked, but fetching a screen's HTML from the  downloadUrl  in the response produced empty files. Each one contained a 403:
Your application is authenticating by using local Application Default Credentials. The stitch.googleapis.com API requires a quota project, which is not set by default.
There are two fixes, and you should apply both:
gcloud auth application-default set-quota-project "$PROJECT_ID"
Then download files with the  download_file  tool, passing the file's resource name ( htmlCode.name  or  screenshot.name  from  get_screen ) rather than fetching the URL yourself. The tool request carries your project context; a direct URL fetch doesn't.
All ten screens then downloaded as complete Tailwind HTML with the design system inline.



Keep credentials out of the configuration

At one point I pasted a raw access token into  mcp.json  to get unblocked. It worked, but it put a live credential in a project file, and the token expires after about an hour anyway. My  mcp.json  is listed in  .gitignore , but that's a safety net. Placeholders are the real control.

Know which environment Kiro reads

Kiro expands  ${STITCH_ACCESS_TOKEN}  from the environment of the process that launched Kiro. In practice:
  • Exporting a variable in a terminal after Kiro is already running has no effect on that instance.
  • Adding an export to  ~/.zshrc  only affects new shells and the Kiro instances started from them.
  • A  .env  file isn't loaded automatically. Something has to source it.
If you keep the values in  .env , launch Kiro from a shell that exports them:
set -a; source .env; set +a
kiro . # or: kiro-cli chat
If that  .env  also contains application secrets, such as database passwords, they all enter Kiro's environment. Consider a dedicated file for Stitch values.

"Does not support dynamic client registration" can mean an expired token

After a break, every call failed with:
MCP tool call failed: Incompatible auth server: does not support dynamic client registration
This points toward OAuth client configuration, but the cause was simpler, the access token had expired. When the server rejects the Bearer token, Kiro attempts its own OAuth sign-in, which relies on Dynamic Client Registration. Google's authorization server doesn't support that, so the error you see describes the fallback rather than the original failure.
Check the token without printing it:
curl -s "https://oauth2.googleapis.com/tokeninfo?access_token=$STITCH_ACCESS_TOKEN"
An  invalid_token  response means you should mint a new token and relaunch Kiro.



The final configuration

One-time Google Cloud setup
gcloud auth login
gcloud auth application-default login

PROJECT_ID="your-project-id"
gcloud config set project "$PROJECT_ID"
gcloud services enable stitch.googleapis.com --project="$PROJECT_ID"
gcloud auth application-default set-quota-project "$PROJECT_ID"
gcloud projects add-iam-policy-binding "$PROJECT_ID" \
--member="user:$(gcloud config get-value account)" \
--role="roles/serviceusage.serviceUsageConsumer" \
--condition=None
 .kiro/settings/mcp.json 
{
"mcpServers": {
"stitch": {
"url": "https://stitch.googleapis.com/mcp",
"type": "http",
"headers": {
"Accept": "application/json",
"Authorization": "Bearer ${STITCH_ACCESS_TOKEN}",
"X-Goog-User-Project": "${GOOGLE_CLOUD_PROJECT}"
},
"timeout": 120000
}
}
}
A launcher that mints a fresh token (add to  ~/.zshrc or ~/.bashrc)
kiro-stitch() {
export GOOGLE_CLOUD_PROJECT="$(gcloud config get-value project 2>/dev/null)"
export STITCH_ACCESS_TOKEN="$(gcloud auth application-default print-access-token)"
kiro "${@:-.}"
}
Run  kiro-stitch  to open Kiro with a token valid for about an hour. When it expires, close Kiro and run it again. No secrets are written to disk.
Verify
Check  /mcp  for  stitch ● running , then ask the agent to list your Stitch projects.



Confirm the agent used the MCP tool

Early on, my agent reported my Stitch projects correctly, and I nearly called the integration finished. Then I noticed it had used  curl  against the endpoint. The Stitch tools weren't bound in that session, so it found another route. The data was real, but it proved the API worked, not the MCP integration.
When you validate any MCP integration, check how the agent produced the answer. A real MCP call appears as a tool invocation attributed to the server, such as  stitch::list_projects . A shell command means the integration still needs work.



Troubleshooting reference

Symptom
Likely cause
Fix
Server doesn't load
Invalid JSON
 python3 -m json.tool .kiro/settings/mcp.json 
 /mcp  shows running, tool list is empty
Servers still connecting
Wait a few seconds; trust  /mcp 
"Expected OAuth 2 access token"
API key can't access project data
Use OAuth headers
"Stitch API has not been used in project..."
API not enabled
 gcloud services enable stitch.googleapis.com 
403 "requires a quota project"
ADC has no quota project
 set-quota-project , and use  download_file 
 ${VAR}  resolves to nothing
Variable missing from Kiro's launch environment
Export before launching, then relaunch
"does not support dynamic client registration"
Expired access token
Mint a new token and relaunch



Key takeaways

Each problem was small. What slowed me down was that several errors described a symptom rather than the cause. These practices apply to any remote MCP server you connect to Kiro:
  1. Validate configuration after every change.
  1. Use live status ( /mcp ) as the source of truth.
  1. Test with a tool call that reads real data, and use  curl  against the JSON-RPC endpoint to see raw errors.
  1. Keep secrets in environment variables, and know which process environment Kiro inherits.
  1. Treat short-lived tokens as an operational concern and script the refresh.
  1. Verify how your agent reached its answer.

With the integration working, my agent now pulls screens from Stitch, maps them to app routes, and generates the Flutter theme from the design tokens. That's the workflow I was after, and it's now a single command to start.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article