AA

app-appplayer/mcp_llm

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

7 stars 6 forks 质量 60 趋势 35MIT

A comprehensive Dart package for integrating Large Language Models (LLMs) with the Model Context Protocol.

概览

A comprehensive Dart package for integrating Large Language Models (LLMs) with the Model Context Protocol. Provides multi-provider LLM access, MCP client/server orchestration, and Contract Layer adapters for the mcp_bundle ecosystem. - Claude (Anthropic) - OpenAI - Gemini (Google) - Vertex AI - Bedrock (AWS) - Cohere - Mistral - Groq - Together - Custom (build your own) - — Google Cloud Vision, OpenAI GPT-4 Vision - — OpenAI Whisper, Google Cloud Speech-to-Text - — Google Cloud Vision OCR, AWS Textract - — AWS S3, Google Cloud Storage - Multi-client and multi-server management - Service routing, balancing, and pooling - Every MCP revision the connected mcp_client / mcp_server speaks (2024-11-05 through 2026-07-28); MCP values are the protocol's generated types (package:mcp_llm/mcp_types.

README

以下为原文 README 节选,完整内容请查看原文。

MCP LLM

A comprehensive Dart package for integrating Large Language Models (LLMs) with the Model Context Protocol. Provides multi-provider LLM access, MCP client/server orchestration, and Contract Layer adapters for the mcp_bundle ecosystem.

Features

LLM Providers

Text/chat:

  • Claude (Anthropic)
  • OpenAI
  • Gemini (Google)
  • Vertex AI
  • Bedrock (AWS)
  • Cohere
  • Mistral
  • Groq
  • Together
  • Custom (build your own)

Cloud capability providers:

  • Vision — Google Cloud Vision, OpenAI GPT-4 Vision
  • ASR — OpenAI Whisper, Google Cloud Speech-to-Text
  • OCR — Google Cloud Vision OCR, AWS Textract
  • Binary storage — AWS S3, Google Cloud Storage

MCP Integration

  • Multi-client and multi-server management
  • Service routing, balancing, and pooling
  • Every MCP revision the connected mcp_client / mcp_server speaks (2024-11-05 through 2026-07-28); MCP values are the protocol’s generated types (package:mcp_llm/mcp_types.dart)
  • Authorization through the MCP client (McpOAuth in mcp_client)
  • Typed MCP layer: every listing page, tool results rendered by content kind, sampling answered by a provider
  • Tool calls run with the arguments the model gave, each keeping one id from the model’s turn to its result
  • Images and stop sequences sent in each provider’s API format
  • Per-peer records: declared capabilities, health (ping for a client, the server’s health record for a server), lifecycle state
  • Deferred Tool Loading (60–80% token reduction)
  • Multi-round tool calling
  • Resource Tool Bridge (mcp_read_resource, mcp_list_resources)

Contract Layer Adapters

Implement mcp_bundle ports so mcp_skill, mcp_profile, mcp_knowledge, and mcp_knowledge_ops can plug mcp_llm providers in directly:

  • LlmPortAdapter
  • AsrPortAdapter
  • OcrPortAdapter
  • VisionPortAdapter
  • StoragePortAdapter

Other

  • Plugin system (custom tools and prompt templates)
  • RAG with document store and vector search (Pinecone, Weaviate)
  • Parallel processing and aggregation
  • Unified logging via Dart logging package

Quick Start

import 'package:mcp_llm/mcp_llm.dart';

Future main() async {
  final provider = ClaudeProvider(
    apiKey: 'your-api-key',
    model: 'claude-sonnet-5-5',
    config: LlmConfiguration(apiKey: 'your-api-key', model: 'claude-sonnet-5-5'),
  );

  final response = await provider.complete(LlmRequest(prompt: 'Hello!'));
  print(response.text);
}

Through the registry, by provider name:

final mcpLlm = McpLlm()..registerProvider('claude', ClaudeProviderFactory());
final client = await mcpLlm.createClient(
  providerName: 'claude',
  config: LlmConfiguration(apiKey: 'your-api-key', model: 'claude-sonnet-5-5'),
);
final reply = await client.chat('Hello!');
print(reply.text);

Using an MCP Server’s Tools

Hand LlmClient a connected mcp_client; chat(enableTools: true) offers the

在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →