ti docs mcp
TI文档MCP服务器——使用语义查询搜索德州仪器文档
概述
ti-docs-mcp是一个mcp(模型上下文协议)服务器,提供德州仪器文档的智能搜索。它使用语义搜索和RAG(检索增强生成)来回答有关TI组件、产品和SDK的技术问题。
特性
- 🔍 语义搜索 --跨TI文档和本地嵌入的自然语言查询
- 📦 组件查找 --按零件号快速访问数据表
- 🏭 产品信息 --TDA4(Jacinto)处理器系列详细信息
- 📚 SDK文档 --使用函数签名搜索SDK API
- 🤖 技术问答 --RAG提供的答案与GLM 4.7集成
安装
来自PyPI(推荐)
pip install ti-docs-mcp来源
git clone https://github.com/openclaw/ti-docs-mcp.git
cd ti-docs-mcp
pip install -e .用法
先决条件
设置GLM 4.7 API关键环境变量:
export GLM_API_KEY="your-glm-api-key"步骤1:索引TI文档
在使用MCP服务器之前,请下载并索引TI文档:
# Download and index TDA4 documents (default: 100 docs)
ti-docs-mcp index
# Download specific product family
ti-docs-mcp index --family TDA4
# Limit number of documents for faster testing
ti-docs-mcp index --max-docs 50
# Clear and rebuild index
ti-docs-mcp index --clear
# Use GPU for faster embeddings (if available)
ti-docs-mcp index --device cuda索引过程中会发生什么:
- 从TI的站点地图中发现URL(考虑4秒爬行延迟)
- 从e2e.ti.com下载HTML文档
- 解析HTML并提取元数据(标题、类型、族、URL)
- 使用以下命令生成本地嵌入
all-MiniLM-L6-v2(384个维度) - 将嵌入存储在ChromaDB矢量数据库中
- 将索引保持为
~/.ti-docs-mcp/index
步骤2:启动MCP服务器
# Start MCP server (stdio transport)
ti-docs-mcp服务器将加载索引,并为MCP客户端提供5个工具。
MCP工具
工具1: ti_search
使用语义查询搜索TI文档。
输入:
query(字符串,必填)--搜索查询document_types(数组,可选)--按类型筛选:["datasheet", "user_guide", "app_note", "reference_design"]product_family(字符串,可选)--按系列筛选(例如“TDA4”、“MSP430”)max_results(整数,可选,默认值:10)--最大结果
退货:
{
"results": [
{
"title": "MSP430FR2355 Watchdog Timer",
"url": "https://e2e.ti.com/...",
"document_type": "user_guide",
"snippet": "Configure the watchdog timer using WDTCTL register...",
"relevance_score": 0.92
}
]
}例子:
# From Python
import asyncio
async def search_docs():
from mcp import Client
client = Client(stdio_transport=True)
result = await client.call_tool(
"ti-docs-mcp",
"ti_search",
arguments={
"query": "watchdog timer configuration",
"document_types": ["user_guide", "datasheet"],
"max_results": 5
}
)
print(result)
asyncio.run(search_docs())______________________________________________________________________
工具2: component_lookup
按零件号查找TI组件。
输入:
part_number(字符串,必填)——TI零件号(例如“TDA4VP8”、“MSP430FR2355”)
退货:
{
"part_number": "TDA4VP8",
"name": "TDA4VP8 Jacinto Processor",
"family": "TDA4",
"package": "BGA",
"description": "Automotive processor with vision acceleration...",
"datasheet_url": "https://e2e.ti.com/...",
"user_guide_url": "https://e2e.ti.com/...",
"key_features": ["VPAC", "HSA", "EVE", "C7x"]
}例子:
await client.call_tool(
"ti-docs-mcp",
"component_lookup",
arguments={"part_number": "TDA4VP8"}
)______________________________________________________________________
工具3: product_info
获取TDA4产品系列信息。
输入:
product_name(字符串,必填)——产品名称(例如“TDA4”、“Jacinto”)
退货:
{
"product_name": "TDA4",
"category": "Automotive Processor",
"description": "TDA4 product family - Jacinto processors for automotive applications",
"applications": ["Automotive", "Industrial", "Robotics"],
"variants": ["TDA4VP8", "TDA4VM", "TDA4VMQ", "AM68A", "AM62A"],
"related_products": ["TDA4VP8", "TDA4VM", "AM68A", "AM62A"]
}例子:
await client.call_tool(
"ti-docs-mcp",
"product_info",
arguments={"product_name": "TDA4"}
)______________________________________________________________________
工具4: sdk_search
搜索SDK文档。
输入:
sdk_name(字符串,必填)--SDK名称(例如,“C2000WARE”、“MSPM0”、“SYSCONFIG”)query(字符串,必填)--在SDK中搜索查询api_version(字符串,可选)-特定的API版本
退货:
{
"sdk_name": "C2000WARE",
"function_name": "initADC",
"description": "Initialize ADC module...",
"parameters": ["adc_base", "clk_div", "adc_num", "adc_sample_time"],
"example": "ADC_init(ADC_BASE, ADC_SAMPLE_TIME);",
"documentation_url": "https://docs.ti.com/c2000ware",
"api_version": "3.1.0"
}例子:
await client.call_tool(
"ti-docs-mcp",
"sdk_search",
arguments={
"sdk_name": "C2000WARE",
"query": "ADC initialization"
}
)______________________________________________________________________
工具5: ti_question
使用TI文档和RAG提出技术问题。
输入:
question(string,必填)——自然语言技术问题context_scope(字符串,可选)--将搜索限制在特定上下文(“组件”、“sdk”、“产品”)
退货:
{
"answer": "To configure the watchdog timer on TDA4VP8, use the WDTCTL register...",
"sources": [
{
"title": "TDA4VP8 User Guide",
"url": "https://e2e.ti.com/...",
"relevance": 0.95
}
],
"confidence": 0.85,
"related_questions": [
"How do I disable the watchdog timer?",
"What is the default watchdog interval?"
]
}例子:
await client.call_tool(
"ti-docs-mcp",
"ti_question",
arguments={"question": "How do I configure the watchdog timer on TDA4VP8?"}
)______________________________________________________________________
与AI代理集成
Gemini CLI
使用Gemini CLI:
# 1. Start ti-docs-mcp MCP server in background
ti-docs-mcp &
# 2. Use Gemini CLI with MCP tools
gemini \
--tool ti-docs-mcp \
--prompt "Search TI documentation for watchdog timer configuration" \
--message "Use ti_search tool to find relevant docs"
# Or use in interactive mode
gemini --tool ti-docs-mcp
# Then in Gemini, use natural language:
# "Search for watchdog timer documentation"
# "Look up TDA4VP8 part number"
# "How do I configure the SPI interface?"Gemini配置:
创建或编辑 ~/.gemini/config:
[mcp.servers.ti-docs-mcp]
enabled = true
command = ["ti-docs-mcp"]
args = ["stdio"]
[tools.ti-docs-mcp]
ti_search = { enabled = true, auto_approve = false }
component_lookup = { enabled = true, auto_approve = false }
product_info = { enabled = true, auto_approve = false }
sdk_search = { enabled = true, auto_approve = false }
ti_question = { enabled = true, auto_approve = false }环境变量:
# For Gemini CLI
export GLM_API_KEY="your-glm-api-key"
# Gemini will auto-connect to ti-docs-mcp when enabled______________________________________________________________________
克劳德桌面
配置:
增添 claude_desktop_config.json:
{
"mcpServers": {
"ti-docs-mcp": {
"command": "ti-docs-mcp"
}
}
}用途:
Claude将自动加载MCP服务器。然后,您可以:
Search TI documentation for "watchdog timer configuration"克劳德会打电话的 ti_search 自动。
______________________________________________________________________
光标IDE
配置:
增添 .cursorrules:
Use ti-docs-mcp to search TI documentation.
Examples:
@ti-docs-mcp ti_search "watchdog timer"
@ti-docs-mcp component_lookup "TDA4VP8"
@ti-docs-mcp ti_question "How do I configure the watchdog timer?"
@ti-docs-mcp product_info "TDA4"
@ti-docs-mcp sdk_search "C2000WARE" "ADC initialization"用途:
光标将自动识别 @ti-docs-mcp 前缀并调用相应的工具。
______________________________________________________________________
Cline(VS代码扩展)
配置:
增添 cline_mcp_settings.json:
{
"mcpServers": {
"ti-docs-mcp": {
"command": "ti-docs-mcp",
"disabled": false
}
}
}用途:
Cline将自动连接到MCP服务器。在聊天中使用:
Search TI documentation for watchdog timer______________________________________________________________________
Continue.dev
配置:
增添 config.json 在 .continue 目录:
{
"mcpServers": {
"ti-docs-mcp": {
"command": "ti-docs-mcp"
}
}
}______________________________________________________________________
其他MCP客户端
任何兼容MCP的客户端都可以连接到 ti-docs-mcp 通过stdio:
# Start server
ti-docs-mcp
# Client will connect via stdio and can call any of the 5 tools______________________________________________________________________
配置
环境变量
# GLM 4.7 API key (required for ti_question tool)
export GLM_API_KEY="your-glm-api-key"
# Optional: Custom index path
export TI_DOCS_INDEX_PATH="~/.ti-docs-mcp/index"
# Optional: Embedding model
export TI_DOCS_TEXT_MODEL="all-MiniLM-L6-v2"
export TI_DOCS_CODE_MODEL="microsoft/codebert-base"
# Optional: Device (cpu/cuda)
export TI_DOCS_DEVICE="cuda"配置文件
创建 ~/.ti-docs-mcp/config.yaml:
# MCP Server
mcp:
name: "ti-docs-mcp"
version: "1.0.0"
# Vector Store
vector_store:
type: "chromadb"
path: "~/.ti-docs-mcp/index"
hnsw_space: "cosine"
# Embeddings (Local Models)
embeddings:
text_model: "all-MiniLM-L6-v2"
code_model: "microsoft/codebert-base"
device: "cpu" # or "cuda" for GPU
batch_size: 100
# GLM 4.7
glm:
api_key: "${GLM_API_KEY}"
model: "glm-4.7"
timeout: 30
# TI Documentation
ti_docs:
product_family: "TDA4"
sitemap_url: "https://e2e.ti.com/sitemapindex-standard.xml"
crawl_delay: 4
max_results: 50
# Chunking
chunking:
text:
chunk_size: 512
chunk_overlap: 50
code:
chunk_size: 512
chunk_overlap: 50______________________________________________________________________
发展
项目结构
ti-docs-mcp/
├── src/ti_docs_mcp/
│ ├── __init__.py
│ ├── cli.py # CLI entry point with index command
│ ├── server.py # MCP server with 5 tools
│ ├── ingest.py # Document download & parsing
│ ├── embeddings.py # Local embedding generation
│ ├── index.py # ChromaDB vector operations
│ └── rag.py # RAG system with GLM 4.7
├── tests/
│ ├── test_server.py # MCP server tests
│ └── test_tools.py # Tool implementation tests
├── .specify/memory/
│ ├── spec.md # Full specification
│ ├── plan.md # Implementation plan
│ ├── tasks.md # Task breakdown
│ └── clarify.md # Clarification answers
├── config.yaml # Default configuration
└── pyproject.toml # Package metadata添加新工具
- 在中定义工具
server.py:
@mcp.tool()
async def my_new_tool(param: str) -> dict:
"""
Tool description here.
Args:
param: Parameter description
Returns:
Tool response
"""
# Your implementation
return {"result": "value"}- 文档在
.specify/memory/spec.md - 更新中的任务列表
.specify/memory/tasks.md - 使用嵌入和向量搜索实现
- 使用MCP客户端进行测试
运行测试
# Run all tests
pytest
# Run specific test file
pytest tests/test_server.py
# Run with coverage
pytest --cov=src/ti_docs_mcp______________________________________________________________________
故障排除
索引中没有文档
# Check if index exists
ls ~/.ti-docs-mcp/index
# Clear and rebuild
ti-docs-mcp index --clearGLM API密钥错误
# Set API key
export GLM_API_KEY="your-key"
# Verify
echo $GLM_API_KEY嵌入生成缓慢
# Use GPU if available
ti-docs-mcp index --device cuda
# Or reduce batch sizeMCP客户端无法连接
确保MCP服务器正在运行:
# Start server in foreground (for debugging)
ti-docs-mcp______________________________________________________________________
演出
- 嵌入生成: 每份文档约50ms(全MiniLM-L6-v2,CPU)
- 矢量搜索: \<50ms(ChromaDB HNSW指数)
- 组件查找: \<100ms(精确匹配搜索)
- 语义搜索: \<200ms(包括嵌入生成)
- 技术问答: \<2s(取决于GLM 4.7响应时间)
______________________________________________________________________
需求
- Python 3.8+
- 最低4GB RAM(用于嵌入和矢量数据库)
- 磁盘空间:约100MB,可容纳1000个文档(ChromaDB+嵌入)
______________________________________________________________________
项目状态
当前版本: 1.0.0(阿尔法-MVP)
已实施:
- ✅ 带stdio传输的MCP服务器
- ✅ 5个具有实际实现的工具
- ✅ 本地嵌入(全MiniLM-L6-v2)
- ✅ ChromaDB矢量数据库
- ✅ 集成GLM 4.7的RAG系统
- ✅ 文档下载和解析(HTML)
- ✅ CLI索引命令
开发中:
- ⏳ PDF解析(pymupdf4llm)
- ⏳ 增量索引更新
- ⏳ 输入验证
- ⏳ 单元测试
- ⏳ 性能优化
______________________________________________________________________
许可证
MIT许可证——有关详细信息,请参阅许可证文件。
贡献
此项目使用规范驱动开发。看 规格套件文档 对于工作流。
致谢
支持
有关问题、疑问或贡献,请访问:
- GitHub问题:https://github.com/openclaw/ti-docs-mcp/issues
- 不一致:https://discord.com/clawd
- 文档:https://docs.openclaw.ai