Skip to main content

Plugin-based framework for blockchain/web3 tools

Project description

Lomen

Lomen is a plugin-based framework for managing blockchain/web3 tools. It provides a unified interface for different blockchain tools with framework adapters for LangChain and MCP.

Features

  • Plugin-based architecture for blockchain/web3 tools
  • Credential management and validation
  • Framework adapters (LangChain, MCP)
  • Type hints and Pydantic validation

Installation

pip install lomen

Requirements

  • Python 3.10+
  • Pydantic >=2.0
  • langchain >=0.1.0
  • python-dotenv >=1.0.0
  • aiohttp >=3.9.0
  • web3 >=6.0.0

Quick Start

# Initialize a plugin with credentials
from lomen.plugins.evm_rpc import EVMRPCPlugin

plugin = EVMRPCPlugin(credentials={"RPC_URL": "https://your-rpc-url"})

# Get the current block number
from lomen.plugins.evm_rpc.tools import GetBlockNumberTool

block_number = GetBlockNumberTool.execute(
    GetBlockNumberTool.Params(),
    credentials={"RPC_URL": "https://your-rpc-url"}
)
print(f"Current block number: {block_number}")

# Use with LangChain
lc_tools = plugin.get_langchain_tools()

# Use with your LangChain agent or LangGraph
# agent = Agent(tools=lc_tools, ...)

# Use with MCP (Model Context Protocol)
from mcp.server.fastmcp import FastMCP

# Initialize MCP server
mcp_server = FastMCP("my_plugin")

# Register tools with the MCP server
plugin.get_mcp_tools(server=mcp_server)

# Run the MCP server
mcp_server.run(transport="stdio")  # or other transport methods

Creating Custom Plugins

To create a custom plugin:

  1. Subclass BasePlugin and implement the required methods
  2. Create tools by implementing the BaseTool interface
  3. Register your plugin and tools

Example:

from typing import List, Type, Dict, Any
from pydantic import BaseModel, Field
from lomen.plugins.base import BasePlugin, BaseTool

class MyCustomTool(BaseTool):
    name = "my_custom_tool"
    
    class Params(BaseModel):
        param1: str = Field(..., description="Parameter description")
    
    @classmethod
    def execute(cls, params: Params, credentials: Dict[str, Any]):
        # Tool implementation
        return f"Result: {params.param1}"

class MyPlugin(BasePlugin):
    @property
    def name(self) -> str:
        return "my_plugin"
    
    @property
    def required_credentials(self) -> List[str]:
        return ["API_KEY"]
    
    @property
    def tools(self) -> List[Type[BaseTool]]:
        return [MyCustomTool]

Contributing

We welcome contributions to Lomen! Please see the contributing guidelines for more information.

Development

To set up for development:

# Clone the repository
git clone https://github.com/username/lomen.git
cd lomen

# Install with development dependencies
pip install -e ".[dev]"

# Run tests
pytest

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lomen-0.1.0.tar.gz (163.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lomen-0.1.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file lomen-0.1.0.tar.gz.

File metadata

  • Download URL: lomen-0.1.0.tar.gz
  • Upload date:
  • Size: 163.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for lomen-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9f1336550a8c8c94b06975209e62d92fa500042c1f9ee9191c29e84e0380e010
MD5 0f13c3d3580a3a03bc8ba91ad8103965
BLAKE2b-256 81cd7d870fd16f015ee816f337379146b23936ad1d6debe418e72c31ae831d28

See more details on using hashes here.

File details

Details for the file lomen-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: lomen-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for lomen-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 74d51f22ecf840325e2414bae062b45a0f64e2d40bf222b0e7524348433d432d
MD5 b4d45ae76a8bbfd082dd95fe2abb4d7a
BLAKE2b-256 474f6153d6a0ec8b7ccc85ef1bac1bdd45f3e60ca37cc4cab33d804ab0990414

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page