MCP ExplorerExplorer

React Mcp

@KelvinQiu802on 19 days ago
233 MIT
FreeCommunity
AI Systems
ReAct + MCP = Magic

Overview

What is React Mcp

ReAct-MCP is a framework that integrates ReAct with MCP to facilitate complex task execution using OpenAI models. It serves as an interface for tool execution, response handling, and communication between various MCP client instances.

Use cases

Use cases for ReAct-MCP include building intelligent virtual assistants, automating customer service interactions, enhancing user engagement through conversational interfaces, and integrating AI-driven tools in software applications.

How to use

To use ReAct-MCP, clone the repository, navigate to the project directory, install the dependencies, set up your environment variables with the OpenAI API key, and run the main application using the command ‘pnpm run dev’.

Key features

Key features of ReAct-MCP include the initialization of multiple MCP clients, invocation of chat prompts for generating responses, dynamic handling of multi-turn conversations, and secure connections to MCP servers for executing tool calls.

Where to use

ReAct-MCP can be used in various fields such as customer support automation, interactive chatbots, educational tools, and any application requiring complex task management and communication with AI models.

Content

LLM + MCP + RAG

目标

  • Augmented LLM (Chat + MCP + RAG)
  • 不依赖框架
    • LangChain, LlamaIndex, CrewAI, AutoGen
  • MCP
    • 支持配置多个MCP Serves
  • RAG 极度简化板
    • 从知识中检索出有关信息,注入到上下文
  • 任务
    • 阅读网页 → 整理一份总结 → 保存到文件
    • 本地文档 → 查询相关资料 → 注入上下文

The augmented LLM

image.png

classDiagram
    class Agent {
        +init()
        +close()
        +invoke(prompt: string)
        -mcpClients: MCPClient[]
        -llm: ChatOpenAI
        -model: string
        -systemPrompt: string
        -context: string
    }
    class ChatOpenAI {
        +chat(prompt?: string)
        +appendToolResult(toolCallId: string, toolOutput: string)
        -llm: OpenAI
        -model: string
        -messages: OpenAI.Chat.ChatCompletionMessageParam[]
        -tools: Tool[]
    }
    class EmbeddingRetriever {
        +embedDocument(document: string)
        +embedQuery(query: string)
        +retrieve(query: string, topK: number)
        -embeddingModel: string
        -vectorStore: VectorStore
    }
    class MCPClient {
        +init()
        +close()
        +getTools()
        +callTool(name: string, params: Record<string, any>)
        -mcp: Client
        -command: string
        -args: string[]
        -transport: StdioClientTransport
        -tools: Tool[]
    }
    class VectorStore {
        +addEmbedding(embedding: number[], document: string)
        +search(queryEmbedding: number[], topK: number)
        -vectorStore: VectorStoreItem[]
    }
    class VectorStoreItem {
        -embedding: number[]
        -document: string
    }

    Agent --> MCPClient : uses
    Agent --> ChatOpenAI : interacts with
    ChatOpenAI --> ToolCall : manages
    EmbeddingRetriever --> VectorStore : uses
    VectorStore --> VectorStoreItem : contains

依赖

git clone [email protected]:KelvinQiu802/ts-node-esm-template.git
pnpm install
pnpm add dotenv openai @modelcontextprotocol/sdk chalk**

LLM

MCP

RAG

向量

  • 维度
  • 模长
  • 点乘 Dot Product
    • 对应位置元素的积,求和
  • 余弦相似度 cos
    • 1 → 方向完全一致
    • 0 → 垂直
    • -1 → 完全想法

image.png

image.png

image.png

image.png

Tools

No tools

Comments