I recently had the opportunity to build out an Agentic AI system for my employer that would allow tools like a local MySQL database to be accessed by a command line tool like Claude Code. While I was working on this I thought I would make something super easy, a template if you will, that I could share with all my readers. Something that you could follow to create your own Model Context Protocol server for your own local projects. So the quest began! In this post I will show you all you need to set it up using either Node.js (using the @modelcontextprotocol/sdk) or Python (through the use of FastMCP).
Many of you developers out there are familiar with the concept of an API or Application Programming Interface. You might have integrated with one or even built out your own using the REST pattern. Even though you followed REST, you more than likely created your own nuanced changes and implementations that made your API slightly different than someone else’s. Then how did you communicate what was in your API? You probably cobbled together some documentation and put it on a website or through a README file.
MCP is a protocol that standardizes the way LLMs or AI agents access these services. Think of it as a way to wrap around functionality you want to offer and creates an interface that everyone has agreed to. No longer is your interface going to be different than another company. Instead you can set this intermediary up and let AI tools use it the same way it uses tools (or resources) from other companies. Very plug and play! Let’s see how this works.
To get started you need a project that is set up in such a way that it adheres to the standard. Rather than implement all that logic yourself, you can easily incorporate packages to help with that. Then you can simply focus on the tools and resources you are going to offer. For our first example I am going to present a simple Node.js project that is meant to be a simple template with a single tool. The goal here is for you to take the template, fire it up, connect it to something like Claude Code and see how it works. Once you see it in action, you are going to want to implement a ton of functionality. You can even spin up multiple tools in minutes!
To start we want to make sure you have all the packages you are going to need. Below is the contents of our package.json file. We are assuming you are familiar with getting Node.js installed and know that you can simply install all the packages by typing “npm install“.
package.json
{
"type": "module",
"dependencies": {
"@modelcontextprotocol/sdk": "^1.12.0",
"cors": "^2.8.5",
"dotenv": "^16.5.0",
"zod": "^3.25.36"
}
}
We have only a few packages specified. First we have the SDK needed to implement the MCP, then we have cors (which is optional and not actually used in our project, but left in the case you need to make some cross domain requests later), dotenv to handle environment variables (again not used until you need to work with sensitive variables which is most likely the case later) and zod which is to simplify parameter typing/formats.
server.js
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";
// Initialize our server
const server = new McpServer({
name: "mcp-echo",
version: "1.0.0",
capabilities: {
tools: {}
}
});
// Tool definition for echoing text.
server.tool(
"echo",
"Echoes any message passed to it.",
{
message: z.string().describe("The message to echo")
},
async ({ message }) => ({
content: [{ type: "text", text: `Tool echo: ${message}` }]
})
);
// Start our server in Stdio transport mode.
const transport = new StdioServerTransport();
await server.connect(transport);
This is meant to be bare bones. We are setting up our MCP to offer one simple tool called “echo” which will echo back a message we give it. Take these two files, toss them in a directory, run npm install to install the dependencies. Then you are set to go. You can run this in numerous ways including:
Once you have Claude fired up, type “/mcp” to see if it is connected. If it is, you can type a prompt into Claude Code like “Echo the message ‘Hello world!’” and Claude Code should ask you to use your new tool. Say “Yes” and you will see Claude use the tool.
All done! Use the structure of this project to build out your own tooling. Bring in your own packages, define the tool, pick a name and description, define your parameters, define your function body and you are good to go.
In the world of MCP there are two modes (known as transport modes). Standard IO (meant for local work) and Streaming HTTP / Server Side Events (SSE) which is meant for setting up on remote servers and having others connect to it. These project templates were created for the former and there is plenty of docs out there to help you with the latter with minor changes. Develop your project with the intended goal in mind and I suggest starting with standard IO first to get a feel for things. I might do a blog post for a remote streaming transport setup later. I thought I would mention this so you are not confused between the two.
Similar steps as implementing the Node.js project works for FastMCP. Given that Python is a little cleaner and readable in its syntax, it can be done fairly simply. First start by creating a virtual environment (or fire up a new project in an IDE like Pycharm which creates the venv automatically) and install the packages “mcp[cli]”, uv, dotenv and for our example we will also use mysql-connector-python package to connect to a local MySQL server.
You can install all this using: pip install “mcp[cli]”, uv, dotenv, mysql-connector-python
Once all that is installed, all that is left is to create our server.py template.
server.py
from mcp.server.fastmcp import FastMCP
from dotenv import load_dotenv
import os
import mysql.connector
load_dotenv('.env')
# Connect to our MySQL server using environment variables
mysql = mysql.connector.connect(
host=os.getenv("DB_HOST"),
user=os.getenv("DB_USER"),
password=os.getenv("DB_PASS"),
database=os.getenv("DB_DATABASE")
)
# Create our FastMCP server
mcp = FastMCP(name="Demo MySQL Server", host="0.0.0.0", port=8050)
# Simple example of showing all MySQL tables
@mcp.tool()
def show_tables() -> list:
cursor = mysql.cursor()
cursor.execute("SHOW TABLES")
return cursor.fetchall()
# Start our server in standard IO mode.
if __name__ == "__main__":
mcp.run(transport="stdio")
This project assumes you have a .env file set up with the appropriate environment variables. Note: Make sure your local MySQL server is going to hear you and you are using the correct user credentials to login.
As you can see, we import the required packages, connect to our MySQL database, set up our FactMCP server with a name, host and port (which are all optional if you are just doing local) and you define tools by wrapping functions in a @mcp.tool() decorator. Type hint your parameters and return types and lastly start your server.
Connecting this server to Claude Code is pretty similar as the Node.js service. Type: “claude mcp add mcp-mysql-py — python /path/to/your/server.py“. Of course use “python” or “python3” according to your environment and how you typically run your python code.
You can use the same MCP inspector tool to also inspect your Python MCP server if you like. With this project we offered one tool for showing the database tables in the MySQL server.
In this article we explored two very simple layouts for local MCP server implementations. These can be a great starting point for you to build out your own services for AI agentic systems to use various tools and resources. Whether it be to access systems like databases, send requests to APIs for email or even process vast amounts of remote server data, the sky is the limit. I hope you found this quick spin through the projects an easy way for you to get started using MCP and finding out more about other servers out there that you can bring into your projects.
Thank you for reading! 🙂