Token导航 LogoToken导航

MCP Server · AI代理

MCP Host Form Builder

一个集成Ollama LLM和模型上下文协议(MCP)的Python后端服务,通过WebSocket为React前端提供实时流式响应。

stdio官方级别未说明来源级核验工具 0
PythonCursorAI代理

快速开始

作者 / 组织
kdgerona
提供方
kdgerona
运行时
Python

工具数量

0

来源目录标注

资源数量

0

来源目录标注

提示词数量

0

来源目录标注

GitHub Star

0

仓库热度

收录来源

1 个

MCP World

选型结论

MCP Host Form Builder 属于AI代理类 MCP Server,公开资料标注 0 个工具,通过stdio 本地进程接入,适配 Cursor,有可以直接复制的安装命令;接入前要先准备 访问 Token。

分类

AI代理

传输方式

stdio

认证方式

访问 Token

部署方式

公开资料未说明

安装与配置

安装命令

uv run python server.py

公开命令不是通用的启动方式,拼不出可靠配置示例;请在客户端 MCP 配置里按官方文档填写 command 和 args。

上手步骤

  1. 1

    准备运行环境

    stdio 服务在本地起进程,需要先装好 Python,再按安装命令拉取依赖。

  2. 2

    安装服务

    复制下面的安装命令执行;命令里带占位符的位置换成自己的密钥或路径。

  3. 3

    写入客户端配置

    在客户端的 MCP 配置里填启动命令和参数,保存后完全退出客户端再打开,让新配置生效。

  4. 4

    验证是否可用

    连接成功后客户端会列出 0 个工具,随便调一个只读工具确认能返回结果。

接入前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

详细介绍

Ollama MCP 流媒体服务器

一个集成了(各种功能)的完整Python后端 Ollama 大语言模型(LLMs) 与;和;带有 模型上下文协议(MCP) 服务器通过WebSocket向React前端提供实时流式响应。

特点/特性

  • 流式传输大型语言模型(LLM)响应从Ollama模型中实时逐词流式传输
  • MCP集成连接到MCP服务器以增强工具调用功能
  • WebSocket APIReact/前端应用的全双工通信
  • FastAPI 服务器具备健康检查和CORS支持的生产就绪异步服务器
  • 灵活模式使用MCP工具,在简单流媒体模式和完整代理模式之间进行选择
  • 类型安全完整的Python类型提示和验证

建筑学

�����������������
  React Frontend 
��������,��������
          WebSocket
         
��������Ľ������������������������������������
  FastAPI Server (server.py)                 
  - WebSocket endpoint (/ws)                 
  - HTTP endpoints (/health, /info, /chat)  
��������,������������������������������������
         
��������Ľ������������������������������������
  StreamingOllamaAgent                       
  - Token streaming                          
  - MCP integration                          
��������,������������������������������������
         
    ����Ľ�����        ����������
      Ollama             MCP    
      Server            Server  
    ����������        ����������

快速入门

先决条件

  • Python 3.13及以上版本
  • 紫外线 包管理器
  • 本地运行的Ollama(默认地址:http://localhost:11434)
  • MCP 服务器正在运行(默认地址:http://localhost:8006/sse)

安装

  1. 克隆并设置:
# Install dependencies
uv sync

# Copy environment configuration
cp .env.example .env

# Edit .env with your configuration
  1. 配置环境 (.env):
# MCP Server Configuration
MCP_SERVER_URL=http://localhost:8006/sse

# Ollama Configuration
OLLAMA_MODEL=skaiform-assistant:gpt-oss
OLLAMA_BASE_URL=http://localhost:11434

# Agent Configuration
MAX_STEPS=30

# WebSocket Server Configuration
SERVER_HOST=0.0.0.0
SERVER_PORT=8000
CORS_ORIGINS=http://localhost:3000,http://localhost:5173
  1. 启动服务器:
# Using uv
uv run python server.py

# Or with uvicorn directly
uvicorn server:app --reload --host 0.0.0.0 --port 8000

服务器将在 http://localhost:8000

API 文档

WebSocket 终端点: /ws

客户端-服务器消息格式
{
  "prompt": "Your question or prompt here",
  "mode": "agent"  // "agent" or "simple" (optional, default: "agent")
}

模式:

  • agent全代理模式,支持MCP工具调用和多步推理
  • simple直接LLM流式传输,无需代理复杂性
服务器-客户端消息格式

所有消息均遵循此结构:

{
  "type": "ollama" | "mcp" | "tool_call" | "tool_result" | "system" | "error" | "done",
  "data": "content string or object"
}

消息类型:

  1. ollama来自Ollama大型语言模型的标记块
   {"type": "ollama", "data": "Hello"}
   {"type": "ollama", "data": " world"}
  1. mcp来自MCP服务器操作的响应
   {"type": "mcp", "data": "Tool execution result"}
  1. tool_call当代理调用MCP工具时
   {
     "type": "tool_call",
     "data": {
       "name": "calculate_md5",
       "args": {"text": "Hello, world!"}
     }
   }
  1. tool_result工具执行结果
   {"type": "tool_result", "data": "Result data"}
  1. system来自服务器的状态消息
   {"type": "system", "data": "Processing your request..."}
  1. error错误信息
   {"type": "error", "data": "Error description"}
  1. done标志着流媒体传输的结束
   {"type": "done", "data": "Response completed"}

HTTP 端点

GET /

带有服务器信息的根端点。

回应:

{
  "name": "Ollama MCP Streaming Server",
  "version": "1.0.0",
  "status": "running",
  "endpoints": {
    "websocket": "/ws",
    "health": "/health",
    "info": "/info"
  }
}
GET /health

健康检查端点。

回应:

{
  "status": "healthy",
  "agent_initialized": true
}
GET /info

服务器配置和状态。

回应:

{
  "ollama_model": "skaiform-assistant:gpt-oss",
  "ollama_base_url": "http://localhost:11434",
  "mcp_server_url": "http://localhost:8006/sse",
  "max_steps": 30,
  "server": {
    "host": "0.0.0.0",
    "port": 8000,
    "cors_origins": ["http://localhost:3000"]
  }
}
POST /chat

用于测试的非流式HTTP终端。

请求:

{
  "prompt": "What is the meaning of life?"
}

回应:

{
  "responses": [
    {"type": "ollama", "data": "The"},
    {"type": "ollama", "data": " meaning"},
    {"type": "done", "data": "Response completed"}
  ]
}

React 前端集成

WebSocket 客户端示例

import { useEffect, useState, useRef } from 'react';

interface Message {
  type: 'ollama' | 'mcp' | 'tool_call' | 'system' | 'error' | 'done';
  data: string | object;
}

export function useOllamaStream(serverUrl: string = 'ws://localhost:8000/ws') {
  const [messages, setMessages] = useState([]);
  const [isConnected, setIsConnected] = useState(false);
  const [isStreaming, setIsStreaming] = useState(false);
  const ws = useRef(null);

  useEffect(() => {
    // Connect to WebSocket
    ws.current = new WebSocket(serverUrl);

    ws.current.onopen = () => {
      console.log('WebSocket connected');
      setIsConnected(true);
    };

    ws.current.onmessage = (event) => {
      const message: Message = JSON.parse(event.data);

      setMessages((prev) => [...prev, message]);

      if (message.type === 'done') {
        setIsStreaming(false);
      }
    };

    ws.current.onerror = (error) => {
      console.error('WebSocket error:', error);
      setIsConnected(false);
    };

    ws.current.onclose = () => {
      console.log('WebSocket disconnected');
      setIsConnected(false);
    };

    return () => {
      ws.current?.close();
    };
  }, [serverUrl]);

  const sendPrompt = (prompt: string, mode: 'agent' | 'simple' = 'agent') => {
    if (ws.current && isConnected) {
      setMessages([]);
      setIsStreaming(true);
      ws.current.send(JSON.stringify({ prompt, mode }));
    }
  };

  return { messages, isConnected, isStreaming, sendPrompt };
}

在组件中的使用

function ChatInterface() {
  const { messages, isConnected, isStreaming, sendPrompt } = useOllamaStream();
  const [input, setInput] = useState('');

  // Accumulate ollama tokens into a single response
  const response = messages
    .filter((m) => m.type === 'ollama')
    .map((m) => m.data)
    .join('');

  const handleSubmit = (e: React.FormEvent) => {
    e.preventDefault();
    if (input.trim()) {
      sendPrompt(input);
      setInput('');
    }
  };

  return (
    

      
Status: {isConnected ? '=â Connected' : '=4 Disconnected'}

      

        {response}
        {isStreaming && Š}
      

      
         setInput(e.target.value)}
          placeholder="Ask a question..."
          disabled={!isConnected || isStreaming}
        />
        
          Send
        
      

      {/* Tool calls and system messages */}
      

        {messages
          .filter((m) => m.type === 'tool_call' || m.type === 'system')
          .map((m, i) => (
            

              {m.type}: {JSON.stringify(m.data)}
            

          ))}
      

    

  );
}

项目结构

mcp-ollama/
�� server.py              # FastAPI WebSocket server
�� streaming_agent.py     # Streaming agent implementation
�� ollama_agent.py        # Original non-streaming agent
�� main.py               # CLI test script
�� pyproject.toml        # Dependencies
�� .env.example          # Configuration template
�� .env                  # Your configuration (create this)
�� README.md             # This file

核心组件

StreamingOllamaAgent (streaming_agent.py) 翻译为中文是:(流式处理代理脚本.py)

处理核心代理类的:

  • Ollama LLM和MCP客户端的初始化
  • 从Ollama逐个标记地进行流式传输
  • MCP工具集成
  • 错误处理与恢复

关键方法:

  • initialize()建立LLM和MCP连接
  • stream_response(prompt)全代理模式,支持工具调用
  • stream_simple(prompt)简单的大语言模型(LLM)流式处理,无需工具

FastAPI Server (server.py) 翻译为中文是:(服务器.py)

生产就绪的异步服务器,具备:

  • 用于实时流传输的WebSocket终端
  • 用于健康检查和测试的HTTP端点
  • 前端集成的CORS支持
  • 全面日志记录
  • 代理初始化的生命周期管理

发展

运行测试

# Test the basic agent (non-streaming)
python main.py

# Test WebSocket connection
# Use a WebSocket client like wscat:
npm install -g wscat
wscat -c ws://localhost:8000/ws

# Send a message:
{"prompt": "Hello!", "mode": "simple"}

代码检查和格式化

ruff check .
ruff format .

添加依赖项

uv add package-name

配置选项

环境变量

变量默认值描述
MCP_SERVER_URLhttp://localhost:8006/sseMCP服务器SSE端点
OLLAMA_MODELskaiform-assistant:gpt-ossOllama模型名称
OLLAMA_BASE_URLhttp://localhost:11434Ollama 服务器 URL
MAX_STEPS30最大代理推理步骤
SERVER_HOST0.0.0.0WebSocket 服务器主机
SERVER_PORT8000WebSocket 服务器端口
CORS_ORIGINShttp://localhost:3000,...允许的CORS来源

故障排除

WebSocket 连接问题

  1. CORS 错误将您的前端URL添加到 CORS_ORIGINS 在 .env
  2. 连接被拒绝确保服务器正在运行且端口正确
  3. 超时检查Ollama和MCP服务器是否正在运行

Ollama 问题

  1. 未找到模型先拉出模型: ollama pull model-name
  2. 连接被拒绝启动Ollama: ollama serve
  3. 反应迟钝检查Ollama的资源使用情况

MCP服务器问题

  1. 连接失败验证MCP服务器是否在配置的URL上运行
  2. 工具错误检查MCP服务器日志中的工具执行错误

高级用法

定制工具处理

修改 streaming_agent.py 为特定工具类型添加自定义处理:

async for chunk in agent.stream_response(prompt):
    if chunk["type"] == "tool_call":
        tool_name = chunk["data"]["name"]
        # Add custom logic for specific tools
        if tool_name == "my_custom_tool":
            # Handle specially
            pass

    yield chunk

多个MCP服务器

在代理初始化时配置多个MCP服务器:

config = {
    "mcpServers": {
        "server1": {"url": "http://localhost:8006/sse"},
        "server2": {"url": "http://localhost:8007/sse"}
    }
}

认证

为WebSocket连接添加身份验证:

@app.websocket("/ws")
async def websocket_endpoint(websocket: WebSocket, token: str = Query(...)):
    # Verify token
    if not verify_token(token):
        await websocket.close(code=1008)
        return

    await websocket.accept()
    # ... rest of handler

许可证

\[此处填写您的许可证\]

贡献

欢迎贡献!请随时提交拉取请求。

支持

对于问题和疑问:

  • 在GitHub上提交一个问题
  • 检查现有问题以寻找解决方案
  • 查阅相关文件

致谢

工具与能力

工具数量

0

资源数量

0

提示词数量

0

能力标签

实时流式处理Python本地部署LLM集成WebSocket通信MCP协议FastAPI服务

支持客户端

Cursor

数量来自来源目录的标注,具体工具清单以官方文档为准。

典型使用场景

多步任务编排

把拆解、检索、执行串成一条链,模型按步骤调用工具。

长期上下文

把会话、笔记和知识放到外部存储,换个会话还能接着做。

接自有流程

把内部系统和模型连起来,让助手调用已有的工作流。

选择建议

值得选的地方

  • 只提供 0 个工具,职责集中,接入后不容易误操作。
  • 有现成的安装命令,不用自己找入口,照着跑就能起服务。
  • 公开说明写得比较完整,接入前能看清能力边界。

先想清楚的地方

  • stdio 方式要求本地装好 Python,换机器要重新装一遍。
  • 需要自备访问 Token,没有凭据没法直接试。
  • 第三方目录整理,版本更新和行为细节以官方仓库为准。

更适合

  • 需要在AI代理场景里让模型直接调用外部能力的人。
  • 已经在用 Cursor 的用户,接入路径最短。
  • 想先快速试一下、能接受在本地跑服务的人。

不太适合

  • 完全不想在本地装环境的人。
  • 暂时拿不到访问 Token的人。
  • 需要厂商级 SLA 和技术支持的生产环境。

同类对比

5 个同类
MCP Server工具数传输方式安装命令收录来源最后核验
MCP Host Form Builder

MCP World · 本页

0stdio有1 个2026-05-17
Everything Claude Code

MCP World

0stdio有1 个2026-05-17
Filesystem 560c4363

MCP World

13未说明未标注2 个2026-05-17
Time 7365cb6d

MCP.so

2SSE有2 个2026-05-17
Server Everything (everything)

MCP World

11stdio有1 个2026-05-17

按同分类和工具数量挑出最接近的几条,字段以各自详情页为准。

常见问题

5 条

MCP Host Form Builder 怎么安装?

公开资料给出的安装命令是 uv run python server.py,运行环境为 Python。装完后按客户端要求写进 MCP 配置,重启客户端生效。

MCP Host Form Builder 怎么在 Claude Desktop、Cursor 里配置?

它是stdio 本地进程,客户端配置里要写启动命令和参数,运行环境是 Python;保存后完全退出客户端再打开,配置才会生效。

MCP Host Form Builder 收费吗?

本站只整理公开资料,不代收费用,也没有标注具体价格。是否收费取决于服务本身和背后的接口额度,正式使用前按官方说明确认。

MCP Host Form Builder 需要 API Key 吗?

公开资料标注的认证方式是访问 Token,也就是要先拿到凭据才能连上;凭据只填在自己本地的配置里,不要写进公开仓库。

MCP Host Form Builder 支持哪些客户端?

公开资料标注支持 Cursor;其他客户端只要能配置 MCP Server,也能用同样的命令或地址接入。

来源信息

继续浏览同类 MCP