• About
  • Privacy Policy
  • Disclaimer
  • Contact
Soft Bliss Academy
No Result
View All Result
  • Home
  • Artificial Intelligence
  • Software Development
  • Machine Learning
  • Research & Academia
  • Startups
  • Home
  • Artificial Intelligence
  • Software Development
  • Machine Learning
  • Research & Academia
  • Startups
Soft Bliss Academy
No Result
View All Result
Home Software Development

Building a Simple To-Do App With Model Context Protocol

softbliss by softbliss
April 28, 2025
in Software Development
0
Building a Simple To-Do App With Model Context Protocol
0
SHARES
0
VIEWS
Share on FacebookShare on Twitter


What Is MCP?

The Model Context Protocol (MCP) is an open protocol that standardizes how applications, tools, and AI models provide and access context. Think of MCP as the “USB-C port for AI applications”—just as USB-C lets you connect all sorts of devices with a single standard, MCP lets you connect AI models, desktop apps, and tools to a wide variety of data sources and capabilities in a consistent way.

MCP is especially useful for building agents and complex workflows on top of large language models (LLMs), making it easy to integrate your own data and tools into AI-powered environments.

Why MCP?

  • Plug-and-play integrations: Connect your code, data, and tools to any MCP-compatible client (like Claude Desktop, IDEs, or custom AI apps).
  • Standardized discovery: Expose your functions, data, and prompts in a way that can be automatically discovered and described.
  • Security and control: Users retain control over what data and actions are shared or executed.

For more, see the official introduction.

MCP Architecture: How Does It Work?

MCP follows a client-server architecture:

  • MCP hosts: Applications like Claude Desktop or IDEs that want to access data and tools via MCP.
  • MCP servers: Lightweight programs (like the to-do app in this article) that expose specific capabilities through MCP.
  • Local/remote data sources: The actual data or services your server connects to.

A host can connect to multiple MCP servers, each exposing different resources, tools, or prompts.

What Can You Expose With MCP?

MCP is flexible and supports several item types:

  • Resources: Data endpoints that provide access to information (e.g., a list of to-dos, a file system, a database table).
  • Tools: Functions or actions that modify data or trigger operations (e.g., add a todo, send an email).
  • Prompts: Templated messages and workflows for users or models.
  • Sampling, roots, and more: For advanced workflows and integrations.

This article focuses on the two most common and fundamental types: resources and tools.
Once you’re comfortable with these, you can explore prompts and other advanced features in the MCP documentation.

Example: To-Do MCP Server in Python

Let’s see how this works in practice with a simple to-do application, implemented as an MCP server.

1. Defining Resources and Tools

In the example repo, server.py uses the mcp Python package to expose a to-do list as both resources and tools:

from mcp.server.fastmcp import FastMCP

mcp = FastMCP("ToDo")

items = []


@mcp.resource("todo://list")
def list_todo():
    """
    List all TODO items.
    """
    return items


@mcp.resource("todo://view/{item_idx}")
def view_todo(item_idx: int):
    """
    View a TODO item.
    """

    if item_idx = len(items):
        return "Item not found"
    return items[item_idx]


@mcp.tool()
def add_todo(value: str):
    """
    Add a TODO item.
    """

    items.append(value)
    return f"Added TODO item: '{value}' at index '{len(items) - 1}'"


@mcp.tool()
def remove_todo(item_idx: int):
    """
    Remove a TODO item.
    """

    if item_idx = len(items):
        return "Item not found"
    removed_item = items.pop(item_idx)

    return f"Removed TODO item: '{removed_item}' from index '{item_idx}'"


@mcp.tool()
def clear_todo():
    """
    Clear all TODO items.
    """

    items.clear()
    return "Cleared all TODO items"


def main() -> None:
    """Run the MCP server."""
    mcp.run()


if __name__ == "__main__":
    main()
  • Resources (with @mcp.resource) are endpoints for data retrieval (e.g., listing or viewing to-dos).
  • Tools (with @mcp.tool) are actions that can be invoked (e.g., adding or removing to-dos).

2. Running the MCP Server

You can run the server locally or in Docker. The server will register its resources and tools so that any MCP-compatible client can discover and use them.

Local Setup

1. Clone the repository:

  • git clone https://github.com/idsulik/todo-mcp-server.git 
  • cd todo-mcp-server

2. Install dependencies:

3. Start the server:

This starts the server and opens the MCP Inspector for interactive testing. The output should look something like this:

Starting MCP inspector...
Proxy server listening on port 6277
MCP Inspector is up and running at http://127.0.0.1:6274

Now, you can open the link http://127.0.0.1:6274 and start interacting with the server.

First of all, you need to click on the connect button:
Click the connect button

After you can open the “Tools” tab, click on the “List Tools” button, select the “add_todo”, paste some content, and click on the “Run Tool”:

Click on Run tool

Now you can open the “Resources” tab, click on the “List Resources” button, and see the to-do item:

See the to-do item

Or, click on the “List Templates”, select the “view_todo”, enter the item’s index(it’s 0) to see the specific item:

Click on List templates

See the specific item

Registering With a Client

To make your server available to an MCP client (like Claude Desktop), run:

mcp install server.py --name "Todo MCP"

If you prefer to add the server manually to your MCP configuration, you can add the following JSON to your Claude:

Desktop configuration file. This is typically located at:

  • ~/.claude-desktop/claude_desktop_config.json on Mac/Linux
  • C:\Users\YourUsername\AppData\Roaming\Claude\claude_desktop_config.json on Windows)
{

  "mcpServers": {
    "todo": {
      "command": "uv",
      "args": [
        "run",
        "--with",
        "mcp[cli]",
        "mcp",
        "run",
        "/path/to/your/server.py"
      ]
    }
  }
}

Replace /path/to/your/server.py with the absolute path to your server.py file. Make sure to use absolute paths, not relative paths.

Using Docker

You can also run this MCP server using Docker without installing anything locally. Add the following to your Claude Desktop configuration:

{
  "mcpServers": {
    "todo": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "idsulik/todo-mcp-server"
      ]
    }
  }
}

Restart your Claude Desktop to see available MCP tools:
Available MCP toolsAvailable MCP tools

Start interacting with the MCP server by asking Claude to add an item to the to-do list, and allow it to use the integration:
Allow
Interact with MCP server

Why Use MCP?

  • No more custom APIs: Expose your Python logic with a few decorators.
  • AI-ready: MCP is designed for AI models and agents to discover and use your tools.
  • Rapid prototyping: Build and test new tools quickly, then connect them to any MCP-enabled client.
  • Security: Users must explicitly consent to data access and tool execution, as recommended by the protocol.

Conclusion

MCP is a powerful new protocol for making your Python code accessible to the next generation of AI-driven tools and applications. With just a few lines of code, you can expose your business logic, data, or automation scripts to any compatible client.

The To-Do MCP Server is a minimal but complete example — clone it, run it, and start building your own MCP-powered tools today!

Learn more:

Tags: AppBuildingContextmodelProtocolSimpleToDo
Previous Post

The Enigma of Enforcing GDPR on LLMs • AI Blog

Next Post

Guide to Reinforcement Finetuning – Analytics Vidhya

softbliss

softbliss

Related Posts

Google AI for game developers
Software Development

Google AI for game developers

by softbliss
May 11, 2025
Unlocking the Future of Finance
Software Development

Unlocking the Future of Finance

by softbliss
May 10, 2025
AI updates from the past week: IBM watsonx Orchestrate updates, web search in Anthropic API, and more — May 9, 2025
Software Development

AI updates from the past week: IBM watsonx Orchestrate updates, web search in Anthropic API, and more — May 9, 2025

by softbliss
May 10, 2025
Automatic Code Transformation With OpenRewrite
Software Development

Automatic Code Transformation With OpenRewrite

by softbliss
May 9, 2025
I’m So Old: Web Edition
Software Development

I’m So Old: Web Edition

by softbliss
May 9, 2025
Next Post
Guide to Reinforcement Finetuning – Analytics Vidhya

Guide to Reinforcement Finetuning - Analytics Vidhya

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Premium Content

Building Grammar, Usage, and Style into Writer’s Workshop

Building Grammar, Usage, and Style into Writer’s Workshop

April 12, 2025
Mixture of Experts LLMs: Key Concepts Explained

Mixture of Experts LLMs: Key Concepts Explained

April 25, 2025
Can AI Imagine? The Rise of Generative Intelligence | by Anika Sharma | Apr, 2025

Can AI Imagine? The Rise of Generative Intelligence | by Anika Sharma | Apr, 2025

April 19, 2025

Browse by Category

  • Artificial Intelligence
  • Machine Learning
  • Research & Academia
  • Software Development
  • Startups

Browse by Tags

Amazon App Apr Artificial Berkeley BigML.com Blog Build Building Business Content Data Development Gemini Generative Google Guide Impact Innovation Intelligence Key Language Large Learning LLM LLMs Machine MIT Mobile model Models News NVIDIA Official opinion OReilly Research Startup Startups Strategies students Tech Tools Understanding Video

Soft Bliss Academy

Welcome to SoftBliss Academy, your go-to source for the latest news, insights, and resources on Artificial Intelligence (AI), Software Development, Machine Learning, Startups, and Research & Academia. We are passionate about exploring the ever-evolving world of technology and providing valuable content for developers, AI enthusiasts, entrepreneurs, and anyone interested in the future of innovation.

Categories

  • Artificial Intelligence
  • Machine Learning
  • Research & Academia
  • Software Development
  • Startups

Recent Posts

  • Our latest advances in robot dexterity
  • Matrix3D: Large Photogrammetry Model All-in-One
  • Help! Can My Principal Really Mandate 4 Weeks of Summer PD?

© 2025 https://softblissacademy.online/- All Rights Reserved

No Result
View All Result
  • Home
  • Artificial Intelligence
  • Software Development
  • Machine Learning
  • Research & Academia
  • Startups

© 2025 https://softblissacademy.online/- All Rights Reserved

Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?