Skip to main content
Glama

PyTorch Documentation Search Tool

FIXES_SUMMARY.md3.94 kB
# PyTorch Documentation Search Tool - Fixes Summary This document summarizes the fixes implemented to resolve issues with the PyTorch Documentation Search tool. ## MCP Integration Fixes (April 2025) ### UVX Configuration The `.uvx/tool.json` file was updated to use the proper UVX-native configuration: **Before:** ```json "entrypoint": { "stdio": { "command": "bash", "args": ["-c", "source ~/miniconda3/etc/profile.d/conda.sh && conda activate pytorch_docs_search && python -m mcp_server_pytorch"] }, "sse": { "command": "bash", "args": ["-c", "source ~/miniconda3/etc/profile.d/conda.sh && conda activate pytorch_docs_search && python -m mcp_server_pytorch --transport sse"] } } ``` **After:** ```json "entrypoint": { "command": "uvx", "args": ["mcp-server-pytorch", "--transport", "sse", "--host", "127.0.0.1", "--port", "5000"] }, "env": { "OPENAI_API_KEY": "${OPENAI_API_KEY}" } ``` ### Data Directory Configuration Added a `--data-dir` command line parameter to specify where data files are stored: ```python parser.add_argument("--data-dir", help="Path to the data directory containing chunks.json and chunks_with_embeddings.json") # Set data directory if provided if args.data_dir: # Update paths to include the provided data directory data_dir = os.path.abspath(args.data_dir) logger.info(f"Using custom data directory: {data_dir}") settings.default_chunks_path = os.path.join(data_dir, "chunks.json") settings.default_embeddings_path = os.path.join(data_dir, "chunks_with_embeddings.json") settings.db_dir = os.path.join(data_dir, "chroma_db") settings.cache_dir = os.path.join(data_dir, "embedding_cache") ``` ### Tool Name Standardization Fixed the mismatch between the tool name in registration scripts and the actual name in the descriptor: **Before:** ```bash claude mcp add pytorch_search stdio "${RUN_SCRIPT}" ``` **After:** ```bash claude mcp add search_pytorch_docs stdio "${RUN_SCRIPT}" ``` ### NumPy 2.0 Compatibility Fix Added a monkey patch for NumPy 2.0+ compatibility with ChromaDB: ```python # Create a compatibility utility module # ptsearch/utils/compat.py """ Compatibility utilities for handling API and library version differences. """ import numpy as np # Add monkey patch for NumPy 2.0+ compatibility with ChromaDB if not hasattr(np, 'float_'): np.float_ = np.float64 ``` Then imported in the core `__init__.py` file: ```python # Import compatibility patches first from ptsearch.utils.compat import * ``` This addresses the error: `AttributeError: `np.float_` was removed in the NumPy 2.0 release. Use `np.float64` instead.` We also directly patched the ChromaDB library file to ensure compatibility: ```python # In chromadb/api/types.py # Images # Patch for NumPy 2.0+ compatibility if not hasattr(np, 'float_'): np.float_ = np.float64 ImageDType = Union[np.uint, np.int_, np.float_] ``` ### OpenAI API Key Validation Improved validation of the OpenAI API key in run scripts and provided clearer error messages: ```bash # Check for OpenAI API key if [ -z "$OPENAI_API_KEY" ]; then echo "Warning: OPENAI_API_KEY environment variable not set." echo "The server will fail to start without this variable." echo "Please set the API key with: export OPENAI_API_KEY=sk-..." exit 1 fi ``` ## Documentation Updates 1. **README.md**: Updated with clearer installation and usage instructions 2. **MCP_INTEGRATION.md**: Improved with correct tool names and data directory information 3. **MIGRATION_REPORT.md**: Updated to reflect the fixed status of the integration 4. **refactoring_implementation_summary.md**: Added section on MCP integration fixes ## Next Steps 1. **Enhanced Data Validation**: Add validation on startup for missing or invalid data files 2. **Configuration Management**: Create a configuration file for persistent settings 3. **UI Improvements**: Add a simple web interface for status monitoring

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/seanmichaelmcgee/pytorch-docs-refactored'

If you have feedback or need assistance with the MCP directory API, please join our Discord server