Version: 0.9.1
date : 2025/10/16
GoLang remoto MCP Server , example
| GOOGLE_GENAI_USE_VERTEXAI=FALSE | |
| GOOGLE_API_KEY=your-key |
| import glob | |
| import os | |
| from langchain_text_splitters import RecursiveCharacterTextSplitter | |
| import ollama | |
| import psycopg2 | |
| from pgvector.psycopg2 import register_vector | |
| # PostgreSQL 接続 | |
| conn = psycopg2.connect( | |
| dbname="mydb", |
| version: "3.9" | |
| services: | |
| db: | |
| image: pgvector/pgvector:pg16 | |
| container_name: pgvector-db | |
| restart: always | |
| environment: | |
| POSTGRES_USER: root | |
| POSTGRES_PASSWORD: admin | |
| POSTGRES_DB: mydb |
| // app/lib/RpcClient.ts | |
| import { spawn } from "child_process"; | |
| class RpcClient { | |
| constructor(command: any) { | |
| /* @ts-ignore */ | |
| this.proc = spawn(command); | |
| /* @ts-ignore */ | |
| this.idCounter = 1; | |
| /* @ts-ignore */ |
| /** | |
| * Cloudflare Workers - MCP Server with JSON-RPC 2.0 | |
| * Model Context Protocol Remote Server Implementation | |
| */ | |
| export default { | |
| async fetch(request, env, ctx) { | |
| // CORS headers | |
| const corsHeaders = { | |
| 'Access-Control-Allow-Origin': '*', |
| const start = async function() { | |
| try{ | |
| const item = { | |
| "jsonrpc": "2.0", | |
| "method": "tools/list", | |
| "id": 2 | |
| } | |
| const response = await fetch("http://localhost:3000/mcp", { |
| [package] | |
| name = "rust_remoto_mcp_1" | |
| version = "0.1.0" | |
| edition = "2024" | |
| [dependencies] | |
| anyhow = "1.0.100" | |
| axum = "0.7.5" | |
| axum-extra = { version = "0.10.1", features = ["cookie"] } | |
| chrono = { version = "0.4", features = ["serde"] } |
| const start = async function() { | |
| try{ | |
| const item = { | |
| "jsonrpc": "2.0", | |
| "method": "tools/list", | |
| "id": 1 | |
| } | |
| const response = await fetch("http://localhost:3000/mcp", { | |
| method: 'POST', |
| import { spawn } from "child_process"; | |
| class RpcClient { | |
| constructor(command) { | |
| this.proc = spawn(command); | |
| this.idCounter = 1; | |
| this.pending = new Map(); | |
| this.proc.stdout.setEncoding("utf8"); | |
| this.proc.stdout.on("data", (data) => this._handleData(data)); |