Token导航 LogoToken导航TokenDH.com
Foxy Contexts logo
AI代理stdio官方级别未说明来源级核验

Foxy Contexts

MCP Server

@modelcontextprotocol/inspector

Foxy Contexts是一个用于构建支持Model Context Protocol的上下文服务器的Golang库,采用声明式方法定义工具、资源和提示。

工具数

0

提示词数

0

GitHub Stars

114

资源数

0
服务器构建GoAI代理

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

strowk

提供方

strowk

最后核验

2026/5/17 20:23

运行时

Node.js

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

npx @modelcontextprotocol/inspector go run main.go

详细介绍

Foxy Contexts

Build MCP Servers Declaratively in Golang

Features 🦊 Tool Example 🦊 Docs 🦊 Sources

Foxy contexts是一个Golang库,用于构建支持 模型上下文协议.

通过这种方法,您可以轻松地将工具/资源/提示的调用/读取/获取逻辑和定义放在一个单独的地方,而依赖注入允许您重用共享部分,如客户端、数据库连接等。

特性

以下是已实施和计划的功能列表:

  • \[x\] 基础(生命周期/ping)

- \[\]进度(计划)

  • \[x\] 运输

- \[x\] 标准运输 - \[x\] 苏格兰和南方能源公司运输 - \[x\] 流式HTTP传输(测试版)

  • \[x\] 工具

- \[x\] 打包工具输入有助于定义工具输入模式并验证到达的输入

  • \[\]资源

- \[x\] 资源-静态 - \[x\] 资源-通过资源提供者动态提供 - \[\]资源-通过资源模板动态(计划) - \[\]资源模板完成(计划中) - \[\]资源订阅

  • \[x\] 提示
  • \[x\] 提示完成
  • \[x\] 功能测试包foxytest
  • \[x\] 使用依赖注入功能简单构建MCP服务器
  • \[\]通过MCP记录(计划)
  • \[\]取样(计划)
  • \[\]根(计划中)
  • \[\]分页(计划中)
  • \[\]通知列表_已更改(计划中)
  • \[x\] 测试-使用foxytest软件包进行功能测试

工具示例

例如,尝试以下操作

git clone https://github.com/strowk/foxy-contexts
cd foxy-contexts/examples/list_current_dir_files_tool
npx @modelcontextprotocol/inspector go run main.go

,然后在浏览器打开时启动检查器http://localhost:6274并尝试使用列表当前dir文件。

以下是该示例的代码 示例/list_current_dir_files_tool/main.go (在实际应用中,您可能希望将其拆分为多个文件):

package main

import (
	"fmt"
	"os"

	"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"
	"go.uber.org/fx/fxevent"
	"go.uber.org/zap"
)

// This example defines list-current-dir-files tool for MCP server, that prints files in the current directory
// , run it with:
// npx @modelcontextprotocol/inspector go run main.go
// , then in browser open http://localhost:6274
// , then click Connect
// , then click List Tools
// , then click list-current-dir-files

// NewListCurrentDirFilesTool defines a tool that lists files in the current directory
func NewListCurrentDirFilesTool() fxctx.Tool {
	return fxctx.NewTool(
		// This information about the tool would be used when it is listed:
		&mcp.Tool{
			Name:        "list-current-dir-files",
			Description: Ptr("Lists files in the current directory"),
			InputSchema: mcp.ToolInputSchema{
				Type:       "object",
				Properties: map[string]map[string]interface{}{},
				Required:   []string{},
			},
		},

		// This is the callback that would be executed when the tool is called:
		func(_ context.Context, args map[string]interface{}) *mcp.CallToolResult {
			files, err := os.ReadDir(".")
			if err != nil {
				return &mcp.CallToolResult{
					IsError: Ptr(true),
					Meta:    map[string]interface{}{},
					Content: []interface{}{
						mcp.TextContent{
							Type: "text",
							Text: fmt.Sprintf("failed to read dir: %v", err),
						},
					},
				}
			}
			var contents []interface{} = make([]interface{}, len(files))
			for i, f := range files {
				contents[i] = mcp.TextContent{
					Type: "text",
					Text: f.Name(),
				}
			}

			return &mcp.CallToolResult{
				Meta:    map[string]interface{}{},
				Content: contents,
				IsError: Ptr(false),
			}
		},
	)
}

func main() {
	app.
		NewBuilder().
		// adding the tool to the app
		WithTool(NewListCurrentDirFilesTool).
		// setting up server
		WithName("list-current-dir-files").
		WithVersion("0.0.1").
		WithTransport(stdio.NewTransport()).
		// Configuring fx logging to only show errors
		WithFxOptions(fx.Provide(func() *zap.Logger {
				cfg := zap.NewDevelopmentConfig()
				cfg.Level.SetLevel(zap.ErrorLevel)
				logger, _ := cfg.Build()
				return logger
			}),
			fx.Option(fx.WithLogger(
				func(logger *zap.Logger) fxevent.Logger {
					return &fxevent.ZapLogger{Logger: logger}
				},
			)),
		).
		Run()
}

func Ptr[T any](v T) *T {
	return &v
}

目录标签

目录标签

服务器构建GoAI代理Golang库本地部署MCP协议声明式编程依赖注入

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Node.js

来源包(packageName,安装包名)

@modelcontextprotocol/inspector

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP