Get the FREE Ultimate OpenClaw Setup Guide →

foxy-contexts

Foxy contexts is a library for building context servers supporting Model Context Protocol

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add strowk-foxy-contexts

How to use

Foxy Contexts is a Golang library for building MCP (Model Context Protocol) servers declaratively. It enables you to define tools, resources, and prompts and register them with an application using a dependency-injection setup (fx). The library focuses on server-side capabilities, allowing you to compose your MCP server by adding tools and transports, then running the server within your Go application. The example in the repository demonstrates building a simple MCP server that exposes a tool (list-current-dir-files) and serving it through a standard transport (stdio) and FX lifecycle. To use this in your own project, you initialize your app builder, register your tools, configure transports, and then call Run to start serving MCP interactions from clients or inspectors.

The tooling and capabilities highlighted include: declarative tool definitions with input schemas, support for the MCP concepts of tools, resources, and prompts, and integration with fx for lifecycle management. You can reuse shared clients, databases, and other dependencies through DI, enabling consistent configuration across your tools and prompts. The provided example shows how a tool can inspect the filesystem and return results in a structured content format that MCP clients can render or process.

How to install

Prerequisites:

  • Go 1.20+ installed and configured in your environment
  • A working GOPATH or Go modules-enabled project

Steps:

  1. Clone the repository or create your own module importing fox Contexts: git clone https://github.com/strowk/foxy-contexts cd foxy-contexts

  2. Initialize a new Go module for your server project (if starting a new project): mkdir my-foxy-server cd my-foxy-server go mod init github.com/yourname/my-foxy-server

  3. Add foxy-contexts as a dependency: go get github.com/strowk/foxy-contexts

  4. Create your MCP server by wiring tools, resources, and prompts using the library APIs as shown in the examples folder of the repository. Build your server binary: go build -o my-foxy-server ./...

  5. Run your server binary: ./my-foxy-server

  6. If you want to experiment with the example from the repository, you can navigate to examples/list_current_dir_files_tool, then run the example using a suitable inspector workflow (as shown in the README’s tool example). You may also adapt the example to your own tool definitions and transports.

Note: If you prefer using containers, you can containerize your Go server by writing a small Dockerfile that builds the Go binary and runs it, then deploy accordingly.

Additional notes

Tips and considerations:

  • Foxy Contexts is focused on server-side behavior; the client-facing interactions are defined by the MCP protocol and your tools/resources/prompts definitions.
  • When wiring tools, ensure each tool has a well-defined InputSchema to help MCP clients validate inputs before invoking the tool.
  • Use FX for dependency injection to share clients, databases, and configurations across tools and transports.
  • The repository references several transports (stdio, SSE, and HTTP stream) which you can enable in your app to suit your deployment environment.
  • For debugging, enable verbose logging in development and limit log noise in production by configuring the logger or using fx options as shown in the example.
  • If you plan to publish or distribute your server, consider bundling your server as a binary and providing a small startup script to configure environment variables and transports at runtime.

Related MCP Servers

Sponsor this space

Reach thousands of developers