Open1
node + GoLang MCP Server , Postgresql 操作メモ
概要
- 前の node + Go MCP Server 関連メモになります
- Postgresql使用
- json-rpc 2.0 で、操作します
- 今回は、ホスティング等対応で。linux build (win WSL) です。
[ 公開 2025/11/08 ]
環境
- node 22
- go version go1.25.3 linux/amd64
- MCP Server
- Postgresql , supabase
- flow

関連
- Go MCP Server + Turso Database
参考したコード
- front-test
- GO MCP Server下記です。
- dev-start
- dist フォルダ下に、Go MCP Server 配置します。
npm run build
npm run dev
- .env
USER_NAME="a1@example.com"
PASSWORD="1111"
- create
- mcp_app12/src-ts/routes/test.ts
router.post('/create', async function(req: any, res: any) {
const retObj = {ret: 500, data: null};
try {
const body = req.body
console.log(body);
const client = new RpcClient(CMD_PATH);
const resp = await client.call(
"tools/call",
{
name: "test_create",
arguments:{
title: body.title,
content: body.content,
}
},
);
client.close();
//console.log("add:", resp);
retObj.ret = 200;
return res.json(retObj);
} catch (error) {
console.error(error);
res.sendStatus(500);
}
});
- list
router.post('/list', async function(req: any, res: any) {
const retObj = {ret: 500, data: null};
try {
const body = req.body
console.log(body);
const client = new RpcClient(CMD_PATH);
const resp = await client.call(
"tools/call",
{
name: "test_list",
arguments:{
content: body.content,
}
},
);
client.close();
let out = [];
if(resp.content[0]){
const json = JSON.parse(resp.content[0].text)
console.log(json)
out = json;
}
retObj.ret = 200;
retObj.data = out;
return res.json(retObj);
} catch (error) {
console.error(error);
res.sendStatus(500);
}
});
-
GO
-
main.go
-
tool 起動
func handleToolsCall(writer *bufio.Writer, req models.JSONRPCRequest) {
var params CallToolParams
if err := json.Unmarshal(req.Params, ¶ms); err != nil {
sendError(writer, req.ID, -32602, "Invalid params")
return
}
if params.Name == "test_create" {
handler.TestCreateHnadler(writer, req)
return
}
if params.Name == "test_list" {
handler.TestListHnadler(writer, req)
return
}
if params.Name == "test_delete" {
handler.TestDeleteHnadler(writer, req)
return
}
if params.Name == "test_update" {
handler.TestUpdateHnadler(writer, req)
return
}
}