generated from wesen/wesen-go-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
750 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,121 @@ | ||
# GO GO TEMPLATE | ||
# go-go-mcp | ||
|
||
A Go implementation of the Model Context Protocol (MCP), providing a framework for building MCP servers and clients. | ||
|
||
## Overview | ||
|
||
This project implements the [Model Context Protocol](https://github.com/modelcontextprotocol/specification), which enables standardized communication between AI applications and language models. The implementation includes: | ||
|
||
- Core protocol message types | ||
- A stdio server implementation | ||
- Support for prompts and logging capabilities | ||
|
||
## Example Server | ||
|
||
The project includes an example stdio server that demonstrates basic MCP functionality: | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"github.com/go-go-golems/go-mcp/pkg" | ||
) | ||
|
||
func main() { | ||
server := NewServer() | ||
if err := server.Start(); err != nil && err != io.EOF { | ||
log.Fatal().Err(err).Msg("Server error") | ||
} | ||
} | ||
``` | ||
_______ _______ _______ _______ | ||
| || | | || | | ||
| ___|| _ | | ___|| _ | | ||
| | __ | | | | | | __ | | | | | ||
| || || |_| | | || || |_| | | ||
| |_| || | | |_| || | | ||
|_______||_______| |_______||_______| | ||
_______ _______ __ __ _______ ___ _______ _______ _______ | ||
| || || |_| || || | | _ || || | | ||
|_ _|| ___|| || _ || | | |_| ||_ _|| ___| | ||
| | | |___ | || |_| || | | | | | | |___ | ||
| | | ___|| || ___|| |___ | | | | | ___| | ||
| | | |___ | ||_|| || | | || _ | | | | |___ | ||
|___| |_______||_| |_||___| |_______||__| |__| |___| |_______| | ||
|
||
### Features | ||
|
||
The example server implements: | ||
|
||
- JSON-RPC 2.0 message handling | ||
- Protocol version negotiation | ||
- Capability declaration | ||
- Structured logging | ||
- Simple prompt system | ||
|
||
### Supported Methods | ||
|
||
- `initialize` - Protocol initialization and capability negotiation | ||
- `ping` - Connection health check | ||
- `prompts/list` - List available prompts | ||
- `prompts/get` - Retrieve prompt content | ||
|
||
### Example Prompt | ||
|
||
The server includes a simple prompt that demonstrates prompt arguments: | ||
|
||
```json | ||
{ | ||
"name": "simple", | ||
"description": "A simple prompt that can take optional context and topic arguments", | ||
"arguments": [ | ||
{ | ||
"name": "context", | ||
"description": "Additional context to consider", | ||
"required": false | ||
}, | ||
{ | ||
"name": "topic", | ||
"description": "Specific topic to focus on", | ||
"required": false | ||
} | ||
] | ||
} | ||
``` | ||
|
||
--- | ||
## Usage | ||
|
||
### Running the Server | ||
|
||
Build and run the example stdio server: | ||
|
||
```bash | ||
go build -o stdio-server go/cmd/stdio-server/main.go | ||
./stdio-server | ||
``` | ||
_______ _______ _______ _______ | ||
| || | | || | | ||
| ___|| _ | | ___|| _ | | ||
| | __ | | | | | | __ | | | | | ||
| || || |_| | | || || |_| | | ||
| |_| || | | |_| || | | ||
|_______||_______| |_______||_______| | ||
_______ _______ ___ _______ __ __ _______ | ||
| || || | | || |_| || | | ||
| ___|| _ || | | ___|| || _____| | ||
| | __ | | | || | | |___ | || |_____ | ||
| || || |_| || |___ | ___|| ||_____ | | ||
| |_| || || || |___ | ||_|| | _____| | | ||
|_______||_______||_______||_______||_| |_||_______| | ||
__ __ _______ ___ _ _______ __ __ _______ ______ _______ | ||
| |_| || _ || | | || | | |_| || || _ | | | | ||
| || |_| || |_| || ___| | || _ || | || | ___| | ||
| || || _|| |___ | || | | || |_|| | |___ | ||
| || || |_ | ___| | || |_| || __ || ___| | ||
| ||_|| || _ || _ || |___ | ||_|| || || | ||| |___ | ||
|_| |_||__| |__||___| |_||_______| |_| |_||_______||___| |||_______| | ||
_______ _______ _______ _______ | ||
| || | | || | | ||
| ___|| _ | | ___|| _ | | ||
| | __ | | | | | | __ | | | | | ||
| || || |_| | | || || |_| | | ||
| |_| || | | |_| || | | ||
|_______||_______| |_______||_______| | ||
_______ _______ ___ _______ __ __ _______ | ||
| || || | | || |_| || | | ||
| ___|| _ || | | ___|| || _____| | ||
| | __ | | | || | | |___ | || |_____ | ||
| || || |_| || |___ | ___|| ||_____ | | ||
| |_| || || || |___ | ||_|| | _____| | | ||
|_______||_______||_______||_______||_| |_||_______| | ||
|
||
### Client Connection | ||
|
||
The server accepts JSON-RPC messages on stdin and writes responses to stdout. Example initialization: | ||
|
||
```json | ||
{ | ||
"jsonrpc": "2.0", | ||
"id": 1, | ||
"method": "initialize", | ||
"params": { | ||
"protocolVersion": "2024-11-05", | ||
"capabilities": {}, | ||
"clientInfo": { | ||
"name": "example-client", | ||
"version": "1.0.0" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Development | ||
|
||
### Project Structure | ||
|
||
- `pkg/` - Core protocol types and utilities | ||
- `cmd/stdio-server/` - Example stdio server implementation | ||
|
||
### Dependencies | ||
|
||
- `github.com/rs/zerolog` - Structured logging | ||
- Standard Go libraries | ||
|
||
## Contributing | ||
|
||
Contributions are welcome! Please feel free to submit a Pull Request. | ||
|
||
## License | ||
|
||
[Insert your chosen license here] |
Oops, something went wrong.