#MCP integration – Support for HTTP /MCP stream?
1 messages · Page 1 of 1 (latest)
me too!... but with no luck
If you want to use that MCP server capability from HA with other tools like Flowise or n8n.. it´s mandatory that you deploy a proper MPC server as described in HA DOC "Install mcp-proxy following the instructions in the README. For example, uv tool install git+https://github.com/sparfenyuk/mcp-proxy. "
"Since most clients do not support native remote servers, you need an additional local MCP server remote gateway."
so I've been trying to deploy that mcp-proxy using portainer in a docker with no luck.. I don't know why I'm having restarts within the image once it´s deployed...
version: "3"
services:
mcp-proxy:
image: ghcr.io/sparfenyuk/mcp-proxy:latest
container_name: mcp-proxy
command: >
--port=8096
--headers Authorization "Bearer YOUR_LONG_TERM_HA_TOKEN"
http://YOUR_HA_IP:8123/mcp_server/sse
ports:
- "8096:8096"
networks:
- default
restart: unless-stopped
networks:
default:
driver: bridge
I've finally got an MCP server up and running using Wrangler and TypeScript. It registers several tools, can save data to a PostgreSQL database, and read from it, making the data accessible via Voice Assist. This is just the beginning, and I have a lot more to implement, with plenty of things that could still go wrong.
cool! may I ask how did you get it? I would really appreciate any help about this
It's still very shaky, at the moment I have broke it by adding more complex features but will probably share everything on github once everything is done.
This is not a complete setup since I have struggle with so many things and diffrent solutions and are not yet sure what to keep. At some point I need to do a fresh reinstall and see all needed steps.
I'm just a newbee in this world.
Create a free Cloudflare account.
On Windows, CMD and navicate to the folder were you want the MCP server.
Execute npm install -g wrangler
You may first need to install npm, nodeJS etc.
Run wrangler login, this will open Cloudflare page to assign your account.
Create a wrangler.toml file with below.
name = "My Secret Project"
main = "scripts/my_tools.ts"
compatibility_date = "2025-07-01"
compatibility_flags = [ "nodejs_compat" ]
[vars]
NODE_ENV = "development"
DATABASE_URL = "postgresql://mcp_user:mcp_password@localhost:5432/mcp_database"
[[migrations]]
new_sqlite_classes = ["MyMCP"]
tag = "v1"
[durable_objects]
bindings = [
{ name = "MCP_OBJECT", class_name = "MyMCP" }
]
[dev]
port = 8790
import { McpAgent } from "agents/mcp";
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";
export class MyMCP extends McpAgent<Env, Record<string, never>, Record<string, never>> {
server = new McpServer({
name: "My MCP Server",
version: "1.0.0",
});
async init() {
this.server.tool(
"my_mcp_tool",
z.object({}),
async () => {
return {
content: [
{
type: "text",
text: "Hello, this is the response from the tool"
}
]
};
}
);
}
}
export default {
fetch(request: Request, env: Env, ctx: ExecutionContext) {
const url = new URL(request.url);
if (url.pathname === "/sse" || url.pathname === "/sse/message") {
return MyMCP.serveSSE("/sse").fetch(request, env, ctx);
}
if (url.pathname === "/mcp") {
return MyMCP.serve("/mcp").fetch(request, env, ctx);
}
return new Response("Not found", { status: 404 });
},
};
Run set DATABASE_URL=postgresql://mcp_user:mcp_password@localhost:5432/mcp_database before starting the wrangler, ihave it in a bat file.
Start the wrangler by run wrangler dev --ip 10.5.0.10 (Your ip the wrangler is running on)
If you want a sql server.
services:
postgres:
image: postgres:17-alpine
container_name: mcp-sql-server
restart: always
environment:
POSTGRES_USER: mcp_user
POSTGRES_PASSWORD: mcp_password
POSTGRES_DB: mcp_database
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD", "pg_isready", "-U", "mcp_user", "-d", "mcp_database"]
interval: 10s
timeout: 5s
retries: 5
volumes:
postgres_data:
The database connection.
import postgres from "postgres";
let dbInstance: postgres.Sql | null = null;
export function getDb(databaseUrl: string): postgres.Sql {
if (!dbInstance) {
dbInstance = postgres(databaseUrl, {
max: 10,
idle_timeout: 30,
connect_timeout: 15,
prepare: true,
});
}
return dbInstance;
}
export async function closeDb(): Promise<void> {
if (dbInstance) {
try {
await dbInstance.end();
} catch (error) {
console.error('Error closing database connection:', error);
} finally {
dbInstance = null;
}
}
}
thank you so much for your detailed answer...I really appreciate that.. but it sadly it exceeds my programming skills 😦
I'm trying to solve this using some available tools and things like n8n or flowise.. and even with that it´s been quite complex..
At first, I couldn’t find any way to get it working myself, so I’m very happy to finally have made some progress. I ran another test using Python, which feels more flexible for my needs after running into issues with TypeScript.
I created a Python STDIO server and exposed it as SSE with this command:
mcp-proxy --debug --sse-port=8080 python mcp_server.py
You can then point the HA MCP integration at http://<ip>:8080/sse, open the OpenAI integration, and select tooltest-server.
Below is a minimal Python script that replies when the tooltest tool is invoked.
#!/usr/bin/env python3
import asyncio
import json
from mcp.server import Server, NotificationOptions
from mcp.server.models import InitializationOptions
import mcp.types as types
import mcp.server.stdio
server = Server("tooltest-server")
@server.list_tools()
async def list_tools() -> list[types.Tool]:
return [
types.Tool(
name="tooltest",
description="Returns a static test message",
inputSchema={
"type": "object",
"properties": {},
"additionalProperties": False
}
)
]
@server.call_tool()
async def call_tool(name: str, arguments: dict | None) -> list[types.TextContent]:
if name == "tooltest":
return [
types.TextContent(
type="text",
text="Test successful!"
)
]
raise ValueError(f"Unknown tool: {name}")
async def main():
async with mcp.server.stdio.stdio_server() as (read_stream, write_stream):
await server.run(
read_stream,
write_stream,
InitializationOptions(
server_name="tooltest-server",
server_version="1.0.0",
capabilities=server.get_capabilities(
notification_options=NotificationOptions(),
experimental_capabilities={}
),
),
)
if __name__ == "__main__":
asyncio.run(main())
Hi. Trying to do this. Why would one require an MCP Proxy? I have n8n and Home Assistant self hosted on the same network. Right now my issue is that it finds the service at /mcp_server/sse but getting 404: Unathorised. I created a Long Live Token and povided that as the API Key with Key = API_ACCESS_TOKEN. Any insights would be appreciated.