What is MCP?
MCP (Model Context Protocol) is a protocol that enables AI agents to communicate with external tools and data sources. By adding MCP servers to Kiro CLI, you can interact with GitHub, databases, documentation, cloud services, and more.
What MCP Enables
| Use Case | Example |
|---|---|
| Documentation | Search AWS docs while implementing |
| Repository | Check GitHub Issues, create PRs |
| Database | Inspect schemas, execute queries |
| Filesystem | File operations within permitted directories |
| Web content | Fetch and analyze web pages |
Configuring MCP Servers
Add via CLI Command
kiro-cli mcp add \
--name aws-docs \
--scope user \
--command uvx \
--args "awslabs.aws-documentation-mcp-server" \
--env "LOG_LEVEL=info" \
--env "PARTITION=aws"
| Option | Description |
|---|---|
--name |
Server name |
--scope |
user (global) or workspace (project) |
--command |
Executable command |
--args |
Command arguments |
--env |
Environment variables (repeatable) |
Add via Configuration File
Configuration files can be placed in two locations:
Workspace level: .kiro/settings/mcp.json
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "${GITHUB_TOKEN}"
}
},
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "./src", "./docs"]
}
}
}
User level: ~/.kiro/settings/mcp.json
User-level settings are available across all projects.
HTTP MCP Servers
Connect to remote MCP servers via HTTP/SSE:
{
"mcpServers": {
"remote-api": {
"type": "http",
"url": "https://api.example.com/mcp"
},
"github-remote": {
"type": "http",
"url": "https://api.github.com/mcp",
"oauth": {
"redirectUri": "http://localhost:38951",
"oauthScopes": ["repo", "user"]
}
}
}
}
OAuth-authenticated remote servers are fully supported.
Managing MCP Servers
# List servers
kiro-cli mcp list
kiro-cli mcp list user # User-level only
kiro-cli mcp list workspace # Workspace-level only
# Check server status
kiro-cli mcp status --name github
# Remove a server
kiro-cli mcp remove --name github
# Import configuration
kiro-cli mcp import --file other-config.json
Within a chat session, use /mcp to see active servers:
> /mcp
Environment Variable Management
MCP server configs reference environment variables with ${VARIABLE_NAME}:
{
"env": {
"GITHUB_TOKEN": "${GITHUB_TOKEN}",
"DATABASE_URL": "${DATABASE_URL}"
}
}
Recommended approaches:
- Shell environment: Set in
.bashrcor.zshrc - .env file: Place in project root (always add to
.gitignore) - Secret managers: AWS Secrets Manager, HashiCorp Vault, etc.
flowchart LR
subgraph CLI["Kiro CLI"]
Agent["AI Agent"]
end
subgraph MCP["MCP Protocol"]
Protocol["JSON-RPC"]
end
subgraph Servers["MCP Servers"]
GH["GitHub Server"]
DB["Database Server"]
FS["Filesystem Server"]
Web["Web Fetch Server"]
end
subgraph External["External Services"]
GitHub["GitHub API"]
PG["PostgreSQL"]
Files["Filesystem"]
WWW["Web"]
end
Agent <--> Protocol
Protocol <--> GH
Protocol <--> DB
Protocol <--> FS
Protocol <--> Web
GH <--> GitHub
DB <--> PG
FS <--> Files
Web <--> WWW
style CLI fill:#3b82f6,color:#fff
style MCP fill:#8b5cf6,color:#fff
style Servers fill:#22c55e,color:#fff
style External fill:#f59e0b,color:#fff
Knowledge Management
Knowledge management makes large document collections searchable without consuming context window tokens. It's an experimental feature.
Adding Knowledge Bases
> /knowledge add --name project-docs --path ./docs
> /knowledge add --name api-reference --path ./api-docs --index-type best
> /knowledge add --name src-code --path ./src --include "*.ts" --exclude "*.test.ts" --index-type fast
| Option | Description |
|---|---|
--name |
Knowledge base name |
--path |
File or directory path |
--include |
File pattern to include |
--exclude |
File pattern to exclude |
--index-type |
fast (BM25) or best (semantic) |
Index Type Selection
| Type | Search Method | Speed | Accuracy | Best For |
|---|---|---|---|---|
| Fast | BM25 lexical | High | Keyword-based | Logs, configs, large codebases |
| Best | Semantic | Slower | Meaning-based | Documentation, research |
Managing Knowledge Bases
> /knowledge show
> /knowledge update --name project-docs
> /knowledge remove --name old-docs
> /knowledge clear
> /knowledge cancel
/knowledge show displays creation date, item count, and background indexing progress for each knowledge base.
Using Knowledge Bases
Registered documents are automatically searched during conversations:
> Tell me about the API authentication approach
Kiro searches registered documents and retrieves relevant information. Tokens are consumed only when searching, so registering large document collections doesn't impact everyday conversations.
Knowledge Bases in Agent Configuration
Define knowledge bases in the agent's resources field:
{
"resources": [
{
"type": "knowledgeBase",
"source": "./docs",
"name": "project-docs",
"description": "Project documentation and API references",
"indexType": "best",
"autoUpdate": true
},
{
"type": "knowledgeBase",
"source": "./src",
"name": "source-code",
"description": "Application source code",
"indexType": "fast",
"autoUpdate": true
}
]
}
Setting autoUpdate: true automatically refreshes the index when files change.
Supported File Types
Text, Markdown, JSON, config files (.ini, .conf, .yaml), code files (Rust, Python, JavaScript, Java, etc.), Dockerfile, Makefile, and many more.
Configuration
# Maximum files per knowledge base
kiro-cli settings knowledge.maxFiles 5000
# Text chunk size
kiro-cli settings knowledge.chunkSize 1000
# Default index type
kiro-cli settings knowledge.indexType best
Per-Agent Isolation
Knowledge bases are isolated per agent at ~/.kiro/knowledge_bases/, with separate directories for each agent. There is no cross-agent access.
Practical Examples
Implementing with Documentation
> Implement S3 multipart upload, referencing the AWS documentation
With an AWS docs MCP server connected, Kiro automatically references the latest documentation.
GitHub Issues Integration
> Check open bug reports and list the high-priority ones
With a GitHub MCP server configured, Kiro directly fetches and analyzes repository issues.
Database Schema Analysis
> Check the database schema and tell me if there's a unique constraint on the email column in the users table
Summary
| Topic | Details |
|---|---|
| MCP | Protocol connecting AI to external tools |
| Configuration | CLI command or config file (.kiro/settings/mcp.json) |
| Server management | kiro-cli mcp list/add/remove/status |
| HTTP servers | Remote connections with OAuth support |
| Knowledge management | /knowledge add for searchable large documents |
| Index types | Fast (BM25) / Best (semantic) |
| Agent isolation | Knowledge bases are independent per agent |
In Day 9, you'll learn about Hooks and Subagents for automation and parallel processing.