viant/mcp 是一个从 https://github.com/viant/mcp. 导入的 MCP 服务器候选。
概览
viant/mcp 是一个从 https://github.com/viant/mcp. 导入的 MCP 服务器候选。
概述(AI 翻译)
MCP 是模型上下文协议(Model Context Protocol)的 Go 实现——这是一种应用程序与 AI 模型通信的标准化方式。它允许开发者通过轻量级的基于 JSON-RPC 的协议无缝衔接应用和 AI 模型。
该仓库提供 Go MCP 客户端/服务器运行时、桥接和认证辅助工具。协议定义和模式存在于 mcp 协议中。
官方模型上下文协议规范
概述
MCP(模型上下文协议)旨在为应用与AI模型之间提供标准化的通信层。该协议通过提供一致的资源访问、提示管理、模型交互和工具调用界面,简化了AI能力与应用的集成。
主要特点:
- 基于JSON-RPC 2.0的通信
- 支持多种传输协议(HTTP/SSE,标准传输)
- 服务器端功能:
- 资源管理
- 模型提示与补全
- 工具调用
- 资源更新订阅
- 伐木
- 进展报告
- 请求取消
- 客户端功能:
- 根源
- 抽样
- 引诱
建筑
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
MCP (Model Context Protocol) for Go
MCP is a Go implementation of the Model Context Protocol — a standardized way for applications to communicate with AI models. It allows developers to seamlessly bridge applications and AI models using a lightweight, JSON-RPC–based protocol.
This repository provides the Go MCP client/server runtime, bridge, and auth helpers. Protocol definitions and schemas live in mcp-protocol.
Official Model Context Protocol Specification
Overview
MCP (Model Context Protocol) is designed to provide a standardized communication layer between applications and AI models. The protocol simplifies the integration of AI capabilities into applications by offering a consistent interface for resource access, prompt management, model interaction, and tool invocation.
Key features:
- JSON-RPC 2.0–based communication
- Support for multiple transport protocols (HTTP/SSE, stdio)
- Server-side features:
- Resource management
- Model prompting and completion
- Tool invocation
- Subscriptions for resource updates
- Logging
- Progress reporting
- Request cancellation
- Client-side features:
- Roots
- Sampling
- Elicitation
Architecture
For detailed guides on custom server implementations and authentication, see docs/implementer.md and docs/authentication.md.
MCP is built around the following components:
- Transport: JSON-RPC over HTTP/SSE, streamable HTTP, or stdio
- Server: Handles incoming requests and dispatches to the protocol implementation
- Client: Makes requests to MCP-compatible servers
- Protocol Implementation (server.Handler): Provides the actual functionality behind each protocol method
High-Level Architecture
graph LR
Client[MCP Client] -->|JSON-RPC / HTTP/SSE| Server[MCP Server]
Server -->|Dispatches to| Handler[MCP Server]
subgraph Auth[Authentication / Authorization]
OAuth2[OAuth2 / OIDC]
end
Client -.->|Bearer Token| OAuth2
Server -.->|Token Validation| OAuth2
Getting Started
Installation
go get github.com/viant/mcp
If you just need to connect existing tools to a remote MCP server you might prefer to use the standalone Bridge binary instead of embedding the Go package. See Bridge Guide for details.
Creating a Server
Quick Start: Default Server
DefaultHandler can be used to quickly set up an MCP server. It provides no-op stubs for all methods, allowing you to focus on implementing only the methods you need. Register handlers inline without writing a custom server type:
package main
import (
"context"
"encoding/json"
"fmt"
"github.com/viant/jsonrpc"
"github.com/viant/mcp-protocol/schema"
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →