Thank you for your interest in langchain-mcp-tools-py!
This guide is focused on the technical aspects of making changes to this project.
- Python 3.11 or higher
- uv - A fast Python package installer and resolver
make
- The project usesMakefile
to simplify the development workflow- git
The following will create and activate a virtual environment using uv
, if not already done,
and install the package using uv pip install -e .
including additional dependencies needed to develop and test.
make install
The project follows a simple and focused architecture:
-
Core functionality: The main module
langchain_mcp_tools.py
contains the functionality to convert MCP server tools into LangChain tools. -
Key components:
convert_mcp_to_langchain_tools
: The main entry point that handles parallel initialization of MCP servers and tool conversionspawn_mcp_server_and_get_transport
: Handles different types of MCP server initialization (stdio, SSE, WebSocket)get_mcp_server_tools
: Converts MCP tools to LangChain format using a custom adapter class
-
Data flow:
- MCP server configurations are provided
- Servers are initialized in parallel
- Available tools are retrieved from each server
- Tools are converted to LangChain format
- A cleanup function is returned to handle resource management
-
Making changes
When making changes, keep the following in mind:
- Maintain type hints for all functions and classes
- Follow the existing code style (the project uses standard Python formatting)
- Add comments for complex logic
-
Test changes quickly
The project includes a simple usage example that can be used to test changes:
make run-simple-usage
-
Running tests
The tests are still in a preliminary stage, but it may help to identify possible bugs.
Please try the following to run the (very small) test suite with pytest.make test
-
Clean build artifacts
Try clean-build once you feel comfortable with your changes.
The following will remove all files that aren't git-controlled, except `.env'.
That means it will remove files you've created that aren't checked in, the virtual environment, and all cache files.make clean
-
Building the package
The following will build the package and verify it's correctly structured.
Note that this will also performmake clean
against the repository, i.e. remove all files other than those controlled by git and the.env
file.make build
This will:
- Clean previous build artifacts
- Install the package in development mode
- Build the distribution packages (wheel and tarball)
- Check the built packages with twine
If you have any questions about development that aren't covered here, please open an issue for discussion.