Back to MCP Catalog

Foxy Contexts MCP Server

Developer ToolsGo
A Golang library for building Model Context Protocol servers declaratively
Available Tools

list-current-dir-files

Lists files in the current directory

Foxy Contexts is a powerful Golang library that enables developers to build context servers supporting the Model Context Protocol (MCP) using a declarative approach. It simplifies the creation of MCP servers by providing a structured way to define tools, resources, and prompts, while leveraging dependency injection for efficient component reuse. With Foxy Contexts, developers can easily organize their code by colocating logic and definitions for each tool, resource, or prompt in separate places, making the codebase more maintainable. The library is built on top of Uber's fx dependency injection framework, allowing for flexible integration of shared components like clients and database connections.

Getting Started with Foxy Contexts

Foxy Contexts is a Golang library for building Model Context Protocol (MCP) servers using a declarative approach. This guide will help you get started with setting up and using Foxy Contexts in your projects.

Installation

To use Foxy Contexts in your Go project, you need to install it using Go modules:

go get github.com/strowk/foxy-contexts

Basic Usage

Here's how to create a simple MCP server with Foxy Contexts:

  1. Import the necessary packages:
import (
    "github.com/strowk/foxy-contexts/pkg/app"
    "github.com/strowk/foxy-contexts/pkg/fxctx"
    "github.com/strowk/foxy-contexts/pkg/mcp"
    "github.com/strowk/foxy-contexts/pkg/stdio"
    "go.uber.org/fx"
)
  1. Define your tools, resources, or prompts:
// Example of defining a tool
func NewMyTool() fxctx.Tool {
    return fxctx.NewTool(
        &mcp.Tool{
            Name:        "my-tool",
            Description: Ptr("Description of my tool"),
            InputSchema: mcp.ToolInputSchema{
                Type:       "object",
                Properties: map[string]map[string]interface{}{
                    // Define your input properties here
                },
                Required: []string{},
            },
        },
        func(ctx context.Context, args map[string]interface{}) *mcp.CallToolResult {
            // Implement your tool logic here
            return &mcp.CallToolResult{
                Content: []interface{}{
                    mcp.TextContent{
                        Type: "text",
                        Text: "Result from my tool",
                    },
                },
            }
        },
    )
}
  1. Create and run your MCP server:
func main() {
    builder := app.NewBuilder()
    
    // Register your tools, resources, or prompts
    builder.RegisterTool(NewMyTool)
    
    // Configure transports (stdio, SSE, or HTTP)
    builder.WithStdioTransport()
    
    // Build and run the application
    builder.Build().Run()
}

Available Transports

Foxy Contexts supports multiple transport mechanisms:

  1. Stdio Transport: For command-line based interactions

    builder.WithStdioTransport()
    
  2. SSE Transport: For Server-Sent Events

    builder.WithSSETransport()
    
  3. HTTP Transport: For HTTP-based communication (beta)

    builder.WithHTTPTransport()
    

Testing Your MCP Server

Foxy Contexts provides a testing package called foxytest for functional testing:

import "github.com/strowk/foxy-contexts/pkg/foxytest"

func TestMyTool(t *testing.T) {
    tester := foxytest.NewTester(t)
    defer tester.Close()
    
    // Register your tool
    tester.RegisterTool(NewMyTool)
    
    // Test your tool
    result := tester.CallTool("my-tool", map[string]interface{}{
        // Tool arguments
    })
    
    // Assert on the result
    // ...
}

Advanced Features

Foxy Contexts supports various MCP features:

  1. Resources: Define static or dynamic resources
  2. Prompts: Create and complete prompts
  3. Dependency Injection: Leverage Uber's fx for DI

Check the official documentation and examples for more detailed information on these features.

Related MCPs

Apple Shortcuts
Developer ToolsJavaScript

Control Apple Shortcuts automations from AI assistants

Clojars Dependency Lookup
Developer ToolsJavaScript

Fetch dependency information from Clojars, the Clojure community's artifact repository

Simple Timeserver
Developer ToolsPython

Provides Claude with current time and timezone information

About Model Context Protocol

Model Context Protocol (MCP) allows AI models to access external tools and services, extending their capabilities beyond their training data.

Generate Cursor Documentation

Save time on coding by generating custom documentation and prompts for Cursor IDE.