mcp

module
v0.9.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2025 License: Apache-2.0

README

MCP Go+ 🚀

Build Status Go Report Card GitHub release GoDoc Language

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

This repo contains two Go+ 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.

Directories

Path Synopsis
demo
calc command
compobj command
hello command
longruntool command
prompt command
resource command
rtx
sse
svx

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL