
portkey-ai/mcp-tool-filter
Analytics & monitoring이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요. 원문 보기
MCP(Model Context Protocol) 서버를 위한 Ultra-fast semantic tool filtering은 유사성을 삽입합니다. 1000+ 도구에서 10ms 미만의 가장 관련 10-20 도구로 축소하십시오.
개요
MCP(Model Context Protocol) 서버를 위한 Ultra-fast semantic tool filtering은 유사성을 삽입합니다. 1000+ 도구에서 가장 관련 10-20 도구로 축소하십시오. - 🚀 : <10ms filtering latency for 1000+ tools with built-inOptimizes - ♨ : 6-8x quick dot product, smart top-K selection, true LRU cache - : 지능형 도구 일치에 대한 embeddings - ♨ : 만 embedding 제공 업체 API를 필요로한다 - ܧ : 채팅 완료 메시지 또는 원시 문자열을 수락 - : Caches embeddings and context forptimum performance - T️ : Tune scoring, top-k 최적화 도구 - 충청남도 초고속 : 1-5ms 지연 시간 - 개인 : 외부 API로 전송되지 않음 - 💰 Free : API 비용 없음 - 인터넷없이 작동 - API 모델보다 낮은 정확도 - 첫 번째 초기화 다운로드 모델 (~25MB) - Xenova/all-MiniLM-L6-v2 (기본) - 384 차원, 매우 빠른 - Xenova/all-MiniLM-L12-v2 - 384 차원, 더 많은 ...
개요(AI 번역)
MCP(Model Context Protocol) 서버를 위한 Ultra-fast semantic tool filtering은 유사성을 삽입합니다. 1000 + 도구에서 도구 컨텍스트를 축소 ** 10ms **에서 가장 관련 10-20 도구로 아래로.
특징
- ⚡ Lightning Fast:`
MCP 서버로 필터를 초기화합니다. 이 precomputes 및 캐시 모든 도구 embeddings.
Note: 시작 중 한 번 호출합니다. 도구 수에 따라 몇 초 정도 걸릴 수 있는 동기화 작업입니다.
filter(input: FilterInput, options?: FilterOptions): Promise
입력 컨텍스트를 기반으로 필터 도구.
** 입력 유형: **
** 옵션 ** (모든 옵션, 과도한 기본값):
리턴스:
getStats()
Filter 상태에 대한 통계를 얻으십시오.
clearCache()
캐시를 삽입할 수 있습니다.
성능 최적화
내장 최적화
라이브러리에는 상자에서 몇 가지 성능 최적화가 포함됩니다.
- ** ♨ 루프-Unrolled Dot 제품** - 벡터 유사성 계산은 CPU 파이프라인 최적화를 통해 6-8x 빠릅니다 2.** Smart Smart Top-K Selection** - Hybrid 알고리즘은 일반적인 워크로드를 위한 빠른 내장 종류, 500개 이상의 도구를 위한 모듈형 선택 스위치를 사용합니다.
- 명세.
이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요.
README
원문 README의 일부입니다. 원문 보기.
@portkey-ai/mcp-tool-filter
Ultra-fast semantic tool filtering for MCP (Model Context Protocol) servers using embedding similarity. Reduce your tool context from 1000+ tools down to the most relevant 10-20 tools in under 10ms.
Features
- ⚡ Lightning Fast: <10ms filtering latency for 1000+ tools with built-in optimizations
- 🚀 Performance Optimized: 6-8x faster dot product, smart top-K selection, true LRU cache
- 🎯 Semantic Understanding: Uses embeddings for intelligent tool matching
- 📦 Zero Dependencies on Runtime: Only requires an embedding provider API
- 🔄 Flexible Input: Accepts chat completion messages or raw strings
- 💾 Smart Caching: Caches embeddings and context for optimal performance
- 🎛️ Configurable: Tune scoring thresholds, top-k, and always-include tools
- 📊 Performance Metrics: Built-in timing for optimization
Installation
npm install @portkey-ai/mcp-tool-filter
Quick Start
import { MCPToolFilter } from '@portkey-ai/mcp-tool-filter';
// 1. Initialize the filter (choose embedding provider)
// Option A: Local Embeddings (RECOMMENDED for low latency < 5ms)
const filter = new MCPToolFilter({
embedding: {
provider: 'local',
}
});
// Option B: API Embeddings (for highest accuracy)
const filter = new MCPToolFilter({
embedding: {
provider: 'openai',
apiKey: process.env.OPENAI_API_KEY,
}
});
// 2. Load your MCP servers (one-time setup)
await filter.initialize(mcpServers);
// 3. Filter tools based on context
const result = await filter.filter(
"Search my emails for the Q4 budget discussion"
);
// 4. Use the filtered tools in your LLM request
console.log(result.tools); // Top 20 most relevant tools
console.log(result.metrics.totalTime); // e.g., "2ms" for local, "500ms" for API
Embedding Provider Options
Local Embeddings (Recommended)
Pros:
- ⚡ Ultra-fast: 1-5ms latency
- 🔒 Private: No data sent to external APIs
- 💰 Free: No API costs
- 🌐 Offline: Works without internet
Cons:
- Slightly lower accuracy than API models
- First initialization downloads model (~25MB)
const filter = new MCPToolFilter({
embedding: {
provider: 'local',
model: 'Xenova/all-MiniLM-L6-v2', // Optional: default model
quantized: true, // Optional: use quantized model for speed (default: true)
}
});
Available Models:
Xenova/all-MiniLM-L6-v2(default) - 384 dimensions, very fastXenova/all-MiniLM-L12-v2- 384 dimensions, more accurateXenova/bge-small-en-v1.5- 384 dimensions, good balanceXenova/bge-base-en-v1.5- 768 dimensions, higher quality
Performance:
- Initialization: 100ms-4s (one-time, downloads model)
- Filter request: 1-5ms
- Cached request: <1ms
API Embeddings
For highest accuracy, use OpenAI or other API providers:
const filter = new MCPToolFilter({
embedding: {
provider: 'openai',
apiKey: process.env.OPENAI_API_KEY,
설치
npx ts-node examples/benchmark.ts