GM
50 stars 0 forks Quality 60 Trend 60

A XGo implementation of the Model Context Protocol (MCP), enabling seamless integration between LLM applications and external data sources and tools.

Overview

A XGo implementation of the Model Context Protocol (MCP), enabling seamless integration between LLM applications and external data sources and tools. This repo contains two XGo classfiles. They are mcp (MCP Server Framework) and mcptest (MCP Server Test Framework). The classfile mcp has the file suffix _mcp.gox (the MCP Server), _res.gox (a MCP Resource or ResourceTemplate), _tool.gox (a MCP Tool) and _prompt.gox (a MCP Prompt). The classfile mcptest has the file suffix _mtest.gox. Here is a MCP Server example (source code). It has two files: main_mcp.gox (the MCP Server) and hello_tool.gox (a MCP Tool). First let us initialize a hello project: Then we have it reference the mcp classfile: The content of main_mcp.gox (the MCP Server) is as follows The content of hello_tool.gox (a MCP Tool) is as follows

README

MCP XGo 🚀

A XGo implementation of the Model Context Protocol (MCP), enabling seamless integration between LLM applications and external data sources and tools.

This repo contains two XGo classfiles. They are mcp (MCP Server Framework) and mcptest (MCP Server Test Framework).

The classfile mcp has the file suffix _mcp.gox (the MCP Server), _res.gox (a MCP Resource or ResourceTemplate), _tool.gox (a MCP Tool) and _prompt.gox (a MCP Prompt). The classfile mcptest has the file suffix _mtest.gox.

mcp: MCP Server Framework

Here is a MCP Server example (source code). It has two files: main_mcp.gox (the MCP Server) and hello_tool.gox (a MCP Tool).

A MCP Server Example: hello

First let us initialize a hello project:

gop mod init hello

Then we have it reference the mcp classfile:

gop get github.com/goplus/mcp@latest

The content of main_mcp.gox (the MCP Server) is as follows

server "Tool Demo 🚀", "1.0.0"

The content of hello_tool.gox (a MCP Tool) is as follows

tool "helloWorld", => {
	description "Say hello to someone"
	string "name", => {
		required
		description "Name of the person to greet"
	}
}

name, ok := ${name}.(string)
if !ok {
	return newError("name must be a string")
}

return text("Hello, ${name}!")

Execute the following commands:

gop mod tidy
gop run .

A simplest MCP Server is running now.

mcptest: MCP Server Test Framework

To test the above hello MCP Server (source code), you only need to implement a hello_mtest.gox file:

mock new(MCPApp)

initialize nil
ret {}

call "helloWorld", {"name": "Ken"}
ret {
	"content": [{"type": "text", "text": "Hello, Ken!"}],
}

Then run gop test or gop test -v to execute the unit test.

View this README on GitHub

Install

This server does not publish a one-line install command.

Open the repository installation guide