The Death of Context Switching: Building an AI Controller with MCP Servers
From the publisher’s feed, collected in the ZeroLabs newsroom.
Part 2 : Skip the Theory. Here’s What We Actually Built.A technical deep-dive into the architecture that made our development workflow 10x fasterWe connected an AI coding agent to 5 MCP servers that gave it real-time access to:Our GitHub repositories (read files, create PRs, monitor CI)Our PostgreSQL database (query schemas, validate data)Our JIRA/Atlassian workspace (fetch stories, read acceptance criteria)Our filesystem (read/write local files)Web fetching (documentation, API references)The result: An AI that doesn’t guess. It queries, verifies, and acts with full context.The MCP ArchitectureMCP Server ConfigurationHere’s our actual mcp.json configuration:{ "mcpServers": { "github": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-github"], "env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_PAT}" } }, "postgres": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-postgres"], "env": { "POSTGRES_CONNECTION_STRING": "postgresql://user:pass@host:5432/db" } }, "atlassian": { "command": "npx", "args": ["-y", "@anthropic/mcp-atlassian"], "env": { "ATLASSIAN_SITE_URL": "https://your-org.atlassian.net", "ATLASSIAN_USER_EMAIL": "${ATLASSIAN_EMAIL}", "ATLASSIAN_API_TOKEN": "${ATLASSIAN_TOKEN}" } }, "fetch": { "command": "npx", "args": ["-y", "@anthropic/mcp-fetch"] } }}What Each MCP Server Provides1. GitHub MCP ServerTools Available:mcp_github_get_file_contents → Read any file from any repomcp_github_search_code → Search across repositoriesmcp_github_create_pull_request → Create PRs programmaticallymcp_github_list_commits → Get commit historymcp_github_push_files → Push changes to branchesmcp_github_create_branch → Create feature branchesReal Usage — Fetching a File, Creating a PRAgent: "I need to see the existing query builder pattern"Tool Call: mcp_github_get_file_contents owner: "your-org" repo: "backend-service" path: "src/dao/QueryBuilder.java"Returns: Full file contents (not a summary, actual code)Tool Call: mcp_github_create_pull_request owner: "your-org" repo: "backend-service" title: "JIRA-1234 Add export feature" body: "## Changes\n- Added ExportService\n- Added unit tests" head: "feature/JIRA-1234-export" base: "master"Returns: PR URL, PR number2. PostgreSQL MCP ServerTools Available:mcp_postgres_query → Execute read-only SQL queries3. Atlassian MCP ServerTools Available:mcp_atlassian_getJiraIssue → Fetch full JIRA ticketmcp_atlassian_searchJiraIssuesUsingJql → Search with JQLmcp_atlassian_getConfluencePage → Fetch documentationmcp_atlassian_addCommentToJiraIssue → Update ticketsThe Complete Workflow (With Actual Tool Calls)Step 1: Fetch RequirementsUser: "Implement PROJ-1234"Agent executes:├── mcp_atlassian_getJiraIssue("PROJ-1234")│ └── Returns: Full ticket with acceptance criteria│├── mcp_github_search_code("similar feature keyword")│ └── Returns: 3 matching files in repo│└── mcp_github_get_file_contents(matching_file_path) └── Returns: Actual implementation to follow as patternStep 2: Understand Current SchemaAgent executes:├── mcp_postgres_query("SELECT * FROM information_schema.tables WHERE...")│ └── Returns: All relevant tables│└── mcp_postgres_query("SELECT column_name, data_type FROM...") └── Returns: Exact column definitions (no guessing)Step 3: ImplementAgent executes:├── read_file(local pattern file) # Native filesystem tool├── create_file(new_service.java) # Native filesystem tool ├── create_file(new_service_test.java) # Native filesystem tool└── run_in_terminal("mvn test") # Verify tests passStep 4: Create PR & Monitor CIAgent executes:├── run_in_terminal("git add -A && git commit -m 'PROJ-1234 Add feature'")├── run_in_terminal("git push origin feature/PROJ-1234")│├── mcp_github_create_pull_request(...)│ └── Returns: PR #507 created│└── Loop until CI passes: ├── run_in_terminal("Invoke-RestMethod .../check-runs") │ └── Returns: { status: "completed", conclusion: "failure" } │ ├── Agent reads failure logs ├── Agent fixes code ├── run_in_terminal("git push") └── Repeat checkCI Monitoring Script (The Agent Runs This)# Agent polls GitHub API for check status$headers = @{ "Authorization" = "Bearer $env:GITHUB_PAT" "Accept" = "application/vnd.github+json"}$response = Invoke-RestMethod ` -Uri "https://api.github.com/repos/org/repo/commits/$SHA/check-runs" ` -Headers $headers$response.check_runs | Select-Object name, status, conclusion# Output:# name status conclusion# ---- ------ ----------# SonarQube completed failure# Unit Tests completed success# Security Scan completed successWhen SonarQube fails, the agent:Fetches the job logsParses the violationsFixes them in codePushes againRe-checksThis loop is fully automated.Real Results With Real NumbersTL;DRMCP servers give AI agents real-time access to your systemsGitHub MCP → Read code, create PRs, monitor CIPostgres MCP → Query schemas, validate dataAtlassian MCP → Fetch JIRA tickets, read ConfluenceAgent knowledge file → Patterns, guardrails, contextResult: AI that doesn’t guess — it queries, verifies, actsThe context switching died because the AI now has the context.Full MCP documentation: https://modelcontextprotocol.ioGitHub MCP Server: https://github.com/modelcontextprotocol/serversAbout the AuthorBuilding AI-powered development workflows. Currently connecting everything to MCP servers ❤️The Death of Context Switching: Building an AI Controller with MCP Servers was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.