Skip to content

feat: langchain-community 工具一键集成 #3

@xiaotonng

Description

@xiaotonng

功能描述

提供对 langchain-community 中常用工具的一键集成支持,用户无需手动编写适配代码即可使用社区已有的数百个工具。

使用场景

from lc2mcp import register_community_tools
from fastmcp import FastMCP

mcp = FastMCP("my-server")

# 一键注册指定的社区工具
register_community_tools(mcp, [
    "DuckDuckGoSearchRun",
    "WikipediaQueryRun", 
    "ArxivQueryRun",
    "PubmedQueryRun",
    "YouTubeSearchTool",
])

# 或者按类别批量注册
register_community_tools(mcp, category="search")  # 所有搜索类工具
register_community_tools(mcp, category="retrieval")  # 所有检索类工具

支持的工具类别

搜索类 (search)

  • DuckDuckGoSearchRun
  • GoogleSearchRun
  • BingSearchRun
  • BraveSearchRun
  • SearxSearchRun

知识库类 (knowledge)

  • WikipediaQueryRun
  • ArxivQueryRun
  • PubmedQueryRun
  • WolframAlphaQueryRun

代码类 (code)

  • PythonREPL
  • ShellTool
  • GitHubAPITool

文件类 (file)

  • FileSearchTool
  • DirectoryReadTool
  • FileReadTool

多媒体类 (media)

  • YouTubeSearchTool
  • ImageGenerationTool

实现建议

  1. 创建 lc2mcp_community/integrations/ 目录存放预配置
  2. 每个工具提供默认的运行时配置和 schema 增强
  3. 自动处理依赖检测(如缺少 duckduckgo-search 时给出友好提示)
  4. 支持懒加载,仅在使用时导入相关依赖

任务清单

  • 整理 langchain-community 中最常用的 50+ 工具
  • 为每个工具创建预配置文件
  • 实现 register_community_tools() 函数
  • 实现工具类别分组
  • 添加依赖检测和友好错误提示
  • 编写文档和示例

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions