How to Import LangChain and MCP Tools into AgentNode
Already have tools built with LangChain, MCP, OpenAI, or CrewAI? The AgentNode Import tool converts them into portable ANP packages in seconds.
The Problem: Framework Lock-In
You have built tools that work. Maybe it is a LangChain tool that queries a database, an MCP server that manages files, or an OpenAI function-calling integration that fetches weather data. These tools do their job — inside the framework they were written for. But the moment you want to share them, use them in a different agent framework, or let someone else install them without understanding your stack, you hit a wall.
The AgentNode Import tool at agentnode.net/import solves this by converting existing tool code into the ANP (AgentNode Package) format — a portable, framework-agnostic standard that any agent can install and use. You paste your code, the converter analyzes it, generates a proper ANP package, and you can publish it to the registry within minutes.
Supported Formats
The import tool currently supports four major frameworks:
- LangChain — Tools built with
@tooldecorator,BaseToolsubclasses, orStructuredTool - MCP (Model Context Protocol) — Server tools using the MCP SDK's
@server.tool()pattern - OpenAI — Function-calling definitions and their implementations
- CrewAI — Tools built with the
@tooldecorator orBaseToolsubclass in CrewAI
The converter auto-detects which framework your code uses based on imports and patterns. You do not need to select it manually.
Step 1: Paste Your Existing Code
Go to agentnode.net/import and paste your tool code into the editor. Here is an example of a LangChain tool you might want to convert:
from langchain.tools import tool
@tool
def word_frequency(text: str, target_word: str) -> dict:
"""Count how many times a specific word appears in the given text.
Args:
text: The text to search through
target_word: The word to count occurrences of
"""
words = text.lower().split()
target = target_word.lower()
count = sum(1 for w in words if w.strip(".,!?;:") == target)
total_words = len(words)
frequency = count / total_words if total_words > 0 else 0.0
return {
"word": target_word,
"count": count,
"total_words": total_words,
"frequency": round(frequency, 6),
}
And here is an MCP server tool example:
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("text-utils")
@mcp.tool()
def word_frequency(text: str, target_word: str) -> dict:
"""Count how many times a specific word appears in the given text."""
words = text.lower().split()
target = target_word.lower()
count = sum(1 for w in words if w.strip(".,!?;:") == target)
total_words = len(words)
frequency = count / total_words if total_words > 0 else 0.0
return {
"word": target_word,
"count": count,
"total_words": total_words,
"frequency": round(frequency, 6),
}
Both of these would produce the same ANP package. The converter strips away the framework-specific decorators and wrappers, keeping only the core logic.
Step 2: Review the Converted Package
After pasting your code, the import tool generates a full ANP package. You will see the manifest.yaml, the converted entrypoint code, and starter tests. Review each file carefully.
The Generated Manifest
manifest_version: "0.2"
package_id: word-frequency
version: "0.1.0"
capabilities:
tools:
- name: word_frequency
entrypoint: word_frequency.tool:word_frequency
input_schema:
type: object
properties:
text:
type: string
description: "The text to search through"
target_word:
type: string
description: "The word to count occurrences of"
required: [text, target_word]
output_schema:
type: object
properties:
word:
type: string
count:
type: integer
total_words:
type: integer
frequency:
type: number
runtime:
language: python
min_version: "3.10"
dependencies: []
Notice what happened: the LangChain @tool decorator was removed. The function's docstring and type hints were used to generate the input_schema and output_schema. The dependencies list is empty because the core logic only uses Python builtins — the converter is smart enough to drop langchain from the dependency list since the converted code no longer needs it.
The Converted Code
def word_frequency(text: str, target_word: str) -> dict:
"""Count how many times a specific word appears in the given text."""
words = text.lower().split()
target = target_word.lower()
count = sum(1 for w in words if w.strip(".,!?;:") == target)
total_words = len(words)
frequency = count / total_words if total_words > 0 else 0.0
return {
"word": target_word,
"count": count,
"total_words": total_words,
"frequency": round(frequency, 6),
}
Clean, portable Python. No framework imports, no decorators, no server boilerplate.
Step 3: Handle Common Conversion Scenarios
Tools with External Dependencies
If your original tool imports third-party libraries (like requests, httpx, or sqlalchemy), the converter detects them and adds them to runtime.dependencies. Double-check that version constraints are correct.
Multi-Tool Servers
If you paste an MCP server with multiple tools, the converter creates a single ANP package with multiple entries under capabilities.tools. Each tool gets its own entrypoint, input_schema, and output_schema. You can also split them into separate packages if you prefer — just publish each tool individually.
Tools with State or Initialization
Some tools depend on initialization logic — database connections, API key loading, or config parsing. The converter preserves this code, but you should review how it is handled. ANP tools are designed to be stateless functions. If your tool requires setup, consider accepting configuration as input parameters or using environment variables that the manifest declares in a permissions block.
OpenAI Function Definitions
For OpenAI imports, you can paste either the function definition JSON and its implementation, or just the Python implementation if it has type hints. The converter maps OpenAI's parameters schema directly to the ANP input_schema.
Step 4: Test Locally
Download the generated files and run the tests on your machine before publishing:
pip install pytest
pytest tests/ -v
Also run the tool manually to verify it behaves the same as the original:
python -c "
from word_frequency.tool import word_frequency
result = word_frequency('the cat sat on the mat', 'the')
print(result)
# Expected: {'word': 'the', 'count': 2, 'total_words': 6, 'frequency': 0.333333}
"
If your original tool had its own tests, port them over. The more tests you include, the higher your verification score after publishing.
Step 5: Publish
Once everything looks right, publish via the web at agentnode.net/publish or using the CLI:
npm install -g agentnode-cli
agentnode login
agentnode publish
The package enters the verification pipeline immediately. Within a minute or two, your package page will display the verification score and tier badge.
Why Convert to ANP?
Converting to ANP is not about abandoning LangChain, MCP, or any other framework. It is about making your tools available everywhere. An ANP package can be installed by any agent regardless of what framework it uses. The tool becomes portable, versioned, verified, and discoverable through the AgentNode registry.
If you built something useful, converting it to ANP takes minutes and gives it a much wider audience. Start at agentnode.net/import.