arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2603.20313cs.SEcs.AI
收藏

面向大语言模型的语义工具发现:基于向量的方法用于MCP工具选择

Semantic Tool Discovery for Large Language Models: A Vector-Based Approach to MCP Tool Selection

Sarat Mudunuri, Jian Wan, Ally Qin, Srinivasan Manoharan

AI总结:

本文提出基于向量检索的语义工具发现架构,通过语义索引和动态选择机制,显著降低工具调用的token消耗,提升效率和准确性。

摘要:

大语言模型(LLMs)通过调用外部工具执行复杂任务展现了巨大潜力。Model Context Protocol(MCP)作为标准化框架,连接LLMs与多样化工具集。然而,当前实现面临可扩展性挑战:向LLM上下文提供所有可用工具导致大量token开销、成本增加、准确性下降和上下文窗口限制。本文提出语义工具发现架构,通过向量检索解决这些问题。我们的方法利用密集嵌入索引MCP工具,捕捉工具能力和用户意图之间的语义关系,动态选择最相关工具(通常3-5个)而非暴露整个工具目录(50-100+)。实验结果表明,在121个工具、5个MCP服务器的140个查询基准上,工具相关token消耗减少99.6%,K=3时命中率97.1%,MRR为0.91,检索延迟低于100毫秒。贡献包括:(1)MCP工具的语义索引框架,(2)基于查询-工具相似度的动态工具选择算法,(3)全面评估显示显著的效率和准确性提升,(4)可扩展到多智能体和跨组织工具发现。

英文摘要:

Large Language Models (LLMs) with tool-calling capabilities have demonstrated remarkable potential in executing complex tasks through external tool integration. The Model Context Protocol (MCP) has emerged as a standardized framework for connecting LLMs to diverse toolsets, with individual MCP servers potentially exposing dozens to hundreds of tools. However, current implementations face a critical scalability challenge: providing all available tools to the LLM context results in substantial token overhead, increased costs, reduced accuracy, and context window constraints. We present a semantic tool discovery architecture that addresses these challenges through vector-based retrieval. Our approach indexes MCP tools using dense embeddings that capture semantic relationships between tool capabilities and user intent, dynamically selecting only the most relevant tools (typically 3-5) rather than exposing the entire tool catalog (50-100+). Experimental results demonstrate a 99.6% reduction in tool-related token consumption with a hit rate of 97.1% at K=3 and an MRR of 0.91 on a benchmark of 140 queries across 121 tools from 5 MCP servers, with sub-100ms retrieval latency. Contributions include: (1) a semantic indexing framework for MCP tools, (2) a dynamic tool selection algorithm based on query-tool similarity, (3) comprehensive evaluation demonstrating significant efficiency and accuracy improvements, and (4) extensibility to multi-agent and cross-organizational tool discovery.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑