ToolKami

MCP sHTTP server (+Cursor integration)

TL;DR: I’m in the midst of migrating ToolKami’s MCP server from SSE to sHTTP. Here is a simple setup that you can use with Cursor too!

Below video shows how easy it is to start the MCP server (in a single command) and have Cursor agent use its tool.

The MCP Server

The main server is only <50 lines combined, there are a few interesting things happening here:

# /// script
# requires-python = ">=3.10"
# dependencies = [
#     "requests>=2,<3",
#     "mcp>=1.2.0,<2",
# ]
# ///

from contextlib import AsyncExitStack, asynccontextmanager

import uvicorn
from starlette.applications import Starlette
from starlette.routing import Mount

from shttp_modules.filesystem import mcp as filesystem_mcp

def combine_lifespans(*lifespans):
    @asynccontextmanager
    async def combined_lifespan(app):
        async with AsyncExitStack() as stack:
            for l in lifespans:
                ctx = l(app)
                await stack.enter_async_context(ctx)
            yield
    return combined_lifespan


main_app = Starlette(
    routes=[
        Mount("/filesystem/", app=filesystem_mcp.streamable_http_app()),
    ],
    lifespan=combine_lifespans(
        lambda _: filesystem_mcp.session_manager.run(),
    ),
)

if __name__ == "__main__":
    uvicorn.run(
        "__main__:main_app",
        host="127.0.0.1",
        port=8002,
        reload=True,
        reload_dirs=["."]
    )

Cursor Client

For Cursor to connect to the server.

Create a new file .cursor/mcp.json

{
    "mcpServers": {
        "toolkami-fs": {
            "url": "http://127.0.0.1:8002/filesystem/mcp"
        }
    }
}

Then go to Cursor > Settings > Cursor Settings > Tools & Integrations to enable the tool:

Cursor Tools & Integrations

Then your agent will be able to start using your tool like in the first video!

Summary

An implementation of everything discussed above can be found here.

It is pretty easy to provide custom, sharp tools to your agent, the tricky part is deciding which tools they should have access to. For code editing, I learnt that having the right diff_fenced_edit_file is critical to defend against catastrophic forgetting - where AI agents overwrite the entire file with cat and delete perfectly functioning code.

I am currently migrating ToolKami which I am using daily to a new setup and will likely document my findings and turn this into a series. Follow this blog or me on X if you’re interested. Thanks for reading and have a nice day!

#AI