A Model Context Protocol (MCP) server for the Linux Foundation's LFX platform, providing tools and resources for interacting with LFX services.
This project implements an MCP server that exposes LFX platform functionality through standardized tools and resources. It's built using the MCP Go SDK and follows the Model Context Protocol specification.
- Hello World Tool: A simple demonstration tool for testing MCP connectivity
- Stdio Transport: Communication via standard input/output streams
- Extensible Architecture: Clean structure for adding new tools and resources
- Go 1.26.0 or later
- Git
-
Clone the repository:
git clone https://github.com/linuxfoundation/lfx-mcp.git cd lfx-mcp -
Install dependencies:
go mod download
-
Build the server:
go build -o bin/lfx-mcp-server ./cmd/lfx-mcp-server
To start the MCP server with stdio transport:
./bin/lfx-mcp-server stdioThe server will listen for MCP messages on stdin and respond on stdout.
A simple greeting tool that demonstrates the MCP tool interface.
Parameters:
name(string, optional): Name to greet (defaults to "World")message(string, optional): Custom greeting message
Example usage:
{
"method": "tools/call",
"params": {
"name": "hello_world",
"arguments": {
"name": "LFX User",
"message": "Welcome"
}
}
}lfx-mcp/
├── cmd/
│ └── lfx-mcp-server/ # Main application entry point
├── internal/
│ └── tools/ # MCP tool implementations
├── bin/ # Built binaries (created by make build)
├── go.mod # Go module definition
├── Makefile # Build automation
└── README.md # This file
Tools are implemented in the internal/tools package for better organization and scalability.
-
Create a new file in
internal/tools/(e.g.,my_tool.go):package tools import ( "context" "github.com/modelcontextprotocol/go-sdk/mcp" ) // MyToolArgs defines the input parameters. type MyToolArgs struct { Param1 string `json:"param1" jsonschema:"Description of parameter 1"` Param2 int `json:"param2,omitempty" jsonschema:"Optional parameter 2"` } // RegisterMyTool registers the tool with the MCP server. func RegisterMyTool(server *mcp.Server) { mcp.AddTool(server, &mcp.Tool{ Name: "my_tool", Description: "Description of what the tool does", }, handleMyTool) } // handleMyTool implements the tool logic. func handleMyTool(ctx context.Context, req *mcp.CallToolRequest, args MyToolArgs) (*mcp.CallToolResult, any, error) { // Your tool implementation here return &mcp.CallToolResult{ Content: []mcp.Content{ &mcp.TextContent{Text: "Tool result"}, }, }, nil, nil }
-
Register your tool in
cmd/lfx-mcp-server/main.go:// Register tools. tools.RegisterHelloWorld(server) tools.RegisterMyTool(server) // Add your new tool
To test the server manually, you can send JSON-RPC messages via stdio:
# Test server initialization and tool listing
(echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0.0"}}}';
echo '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}';
sleep 1) | ./bin/lfx-mcp-server stdio
# Test calling the hello_world tool
(echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0.0"}}}';
echo '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"hello_world","arguments":{"name":"LFX User","message":"Welcome"}}}';
sleep 1) | ./bin/lfx-mcp-server stdioCopyright The Linux Foundation and each contributor to LFX.
This project’s source code is licensed under the MIT License. A copy of the license is available in LICENSE.
This project’s documentation is licensed under the Creative Commons Attribution 4.0 International License (CC-BY-4.0). A copy of the license is available in LICENSE-docs.