- The Six Figure Developer
- Posts
- Model Context Protocol - The USB-C Port for AI Applications
Model Context Protocol - The USB-C Port for AI Applications
Why your AI coding assistant is guessing, and how to fix it.
What is MCP?
"An open protocol that standardizes how applications provide context to LLMs. Think of MCP like a USB-C port for AI applications. Just as USB-C provides a standardized way to connect your devices to various peripherals and accessories, MCP provides a standardized way to connect AI models to different data sources and tools." - Anthropic - Introducing the Model Context Protocol
Have you ever wished your code could understand English, and execute code based on understanding of natural language the way humans can? The programmer's dream language is one where you can simply tell it "if a user submits a bug ticket, send them a follow up email" without having to explicitly write every single conditional; the language understands context/meaning and executes. While we haven't entered into that dream yet, MCP has brought us significantly closer.
My Problem, How I Stumbled Upon MCP
I spent a lot of time this week learning about MCP (Model-Context-Protocol). I'm building an agentic outbound marketing tool for tech job seekers to help them automate the process to landing a job.
For the last couple of months, my workflow was simple:
1. Give Claude Code access to my CLI tools and scripts
2. Maintain an up-to-date README for context
3. Iterate and test changes quicklyClaude Code would generate feature branches and pull requests for successful implementations."
Because I kept an up do date READ.me, and I would carefully prompt Claude Code, I could have it test features for me quickly on the fly & then generate feature branches and pull requests for every successful feature.
Although this worked, it had it's problems, Claude code didn't have a true understanding of how my app worked when it would execute tests, it was just doing it's best guess work based on the info I would feed it.
That changed when I learned what MCP was.
The Old Way: Working Without MCP
As developers, we're used to working with API's, they give our code a uniform, predictable way of interacting with multiple software systems by giving them a common language to speak when requesting data, asking for changes, etc.
Imagine the difficulty you'd face if rather than an API, you had buttons on a web page, and you had to write a web scraper to click specific buttons in a web browser, programmatically, every time you wanted to make an API request.
// Before MCP: Fragile web scraping approach
const createUserButton = document.querySelector('[data-action="create-user"]');
const userInfoInput = document.querySelector('#user-input');
userInfoInput.value = JSON.stringify({
"id": "1",
"name": "John Doe"
});
createUserButton.click(); // Hope this works! 🤞Disgusting, I know, who would want to live in such a world. This is essentially what Claude Code was doing without MCP, it's the reason why when you use cursor and give it a screenshot of your Figma design, it "kinda" works, but it's often times wrong it a lot of ways, really more like a guesstimation.
Creating a MCP server gave Claude Code a semantic understanding of my code, and now I could communicate with Claude in plain english and have much higher confidence that it would execute what i wanted with confidence. It's like an API layer for LLM's, where you give them understanding of how to interact with outside software systems.
This unlocked a ton of power for my app, because now instead of having to define ever edge case down to the finest detail, so long as my MCP tools defined actions with a well defined schema and told Claude what it can and can't do, I can then allow Claude to orchestrate everything, and it worked beautifully.
In my workflow, I have a web-scraper that i can run from my cli, it scrapes data and saves it to a json file. I can also use my web scraper to interact on websites, let's look at Twitter for example.
The Problem with Heuristics
If we build a web-scraper that has functions that can read tweets, and can leave comments. If we wanted to read a tweet on our timeline, check if it's about Javascript, and then reply with a cool comment about Javascript, we'd have write a heuristic to do keyword checks for terms like "javascript", because our code doesn't have semantic understanding of the text. Then if we find a match, leave a comment:
const tweetText = scrapeTweet(rawTweetData);
if (tweetText.includes('javascript')) {
replyToComment()
} else {
// do nothing
}The problem with this approach is that we're going to miss a lot of valuable opportunities for our scraper to interact with tweets. What if an account tweets
I love coding in react.jsIt's still Javascript related, but our conditional won't catch it, because our code doesn't know to check for React.js.
We could try to solve for this, by setting conditionals for every use case we can imagine:
const keywords = [
'javascript',
'typescript',
'react.js'
'angular.js',
'vue',
// ...so on and so forth
]
const keywordMatchFound = keywords.some(keyword => tweetText.includes(keyword));
if (keywordMatchFound) {
replyToComment()
}While this is better, we are still not picking up on a lot of Javascript related terms, and it relies on the tweet author having perfect spelling and grammar every time which isn't how humans operate in the real world. We need something that can understand the meaning of words, sentences, etc to understand if the author's intent is Javascript related.
In comes an LLM.
How MCP Changes the Game
Using an LLM, we can offload the work of semantic understanding to the LLM and focus on writing code to handle orchestration of actions. Using an MCP server to give our LLM access to our code tools, we can now say:
// MCP Tool registration
import { readTweet } from './ourLLMModule';
registerTool('replyToComments', {
description: 'Reply to a tweet with a JavaScript-related comment',
parameters: {
lengthOfMessage: {
type: 'number',
description: 'Approximate length of the reply'
}
}
});
// Offload tweet understanding to LLM
import readTweet from require('ourLLMModule');
const isTweetJavascriptRelated = readTweet(tweetText, `
PROMPT:
You are tweetReader, and expert tweet tweet text analyst. If a tweet is javascript related (i.e., javsacript, typescript, react.js, etc.) then you reply with true, else return false.
`)
// Much better
if (isTweetJavascriptRelated) {
replyToComments()
}Now, we don't have to write 1,000 conditionals in our code to check if a tweet is Javascript related, we can have the LLM do that work for us. This is a small example of the power of MCP servers, you an now build software applications with the semantic understanding and thinking capabilities of an LLM, and maintain all the power of custom software.
This has worked beautifully in my own side projects, and I'm certain this will boost the capabilities of custom software.
AI is not a magic wand, it certainly has it's limitations. Everyone has experienced the dreaded 'can you fix this bug?', only to have entire parts of your code restructured. While LLM technology isn't perfect, it's pretty damn potent.
As developers, our job is to embrace lifelong learning, consider AI another tool to make you an efficient software engineer.