MCP ExplorerExplorer

Frappe Mcp Python

@codeace-boton 22 days ago
1 MIT
FreeCommunity
AI Systems
A Python project for setting up and running an MCP Server with dynamic tool registration.

Overview

What is Frappe Mcp Python

frappe-mcp-python is a Python-based server designed for dynamic tool registration and execution within the MCP framework. It allows developers to create and manage tools that can be easily integrated and utilized in various applications.

Use cases

Use cases for frappe-mcp-python include developing custom tools for data analysis, creating automated workflows in applications, and integrating with other services through the MCP framework.

How to use

To use frappe-mcp-python, clone the repository from GitHub, install dependencies, and configure the server by adding a configuration file to Claude Desktop. Launch the server using the command ‘uv run main.py’ or start a test server with ‘mcp dev main.py’.

Key features

Key features of frappe-mcp-python include dynamic tool registration from Python files, a structured tool schema for argument management, and support for various transport types for server communication.

Where to use

frappe-mcp-python can be used in fields such as software development, data processing, and automation where dynamic tool execution and integration are required.

Content

Installation

Clone and Install Dependencies

git clone https://github.com/itsAnanth/frappe-mcp-python

cd frappe-mcp-python

uv sync

Add Config file to Claude Desktop

Windows: %appdata%/claude/claude_desktop_config.json

{
  "mcpServers": {
    "frappe-mcp-server": {
      "command": "uv",
      "args": [
        "--directory",
        "D:\\internship\\frappe-mcp-python",
        "run",
        "main.py"
      ]
    }
  }
}

Launch Server

uv run main.py

Launch Test Server

mcp dev main.py

Run the dev server with configuration:

  • transport type: stdio
  • command: uv
  • arguments: --directory "D:\internship\frappe-mcp-python" run main.py

Adding New Tools

The project uses a dynamic tool registration strategy in such a way that all python files under the tools/ directory are read and registered. For a tool to be recognized it needs to follow a certain structure

General Tool Structure

# my_tool.py

# import modules
from pydantic import BaseModel, Field
from typings import Optional
from mcp.types import (
    TextContent
)

class ToolSchema(BaseModel):
  # required arguments and their types
  name: str = Field(..., description="argument description")
  # for optional arguments, provide a default value for field, ... means its mandatory
  age: Optional[int] = Field(None, description="argument description")

def my_tool(clients, arguments):
  """ tool description in detail """

  # access arguments
  name = arguments['name']
  age = arguments['age']

  # perform operations
  output = None 

  return [
    TextContent(
        type="text",
        text=json.dumps(output.result, indent=2)
    )
  ]

exports = {
  "tool": my_tool,
  "tool_schema": ToolSchema,
  "requires": ['frappe_client', 'db_client']
}

Tool Schema

all necessary arguments required to call the tool must be provided here with proper description. Claude will read this schema and pass the necessary arguments in the arguments parameter of the function

In the above example, to access the arguments passed by claude use the arguments parameter

Tool Description

An in-depth description of the tool, its use case and other features can be defined as a doctype denote by triple quotes """ description """ under the tool function, this will be used while registering the tool for claude

Return Type of Tool

Tools must return output wrapped in TextContent class for claude to read it

Exports

This is the most important part of the tool file, every file must have an export object for it to be recognized as a tool

  • tool: the actual function
  • tool_schema: the schema created that consists of arguments and descriptions
  • requires: externals clients if needed (example, frappe_client, db_client)

Tools

No tools

Comments