MicroFn MCP Server (Python)

by microfnhq

122 downloads
Not rated
GitHub

Description

# MicroFn MCP Server (Python) This is a FastMCP server for the MicroFn project. It exposes MCP tools for integration and automation. --- ## Features - **Ping tool**: Test the server with a simple ping/pong. - **list_functions tool**: Lists all functions for the authenticated…

About

# MicroFn MCP Server (Python) This is a FastMCP server for the MicroFn project. It exposes MCP tools for integration and automation. --- ## Features - **Ping tool**: Test the server with a simple ping/pong. - **list_functions tool**: Lists all functions for the authenticated user via the MicroFn API. -…

Details

Author
microfnhq
Downloads
122
Categories
Other

- Test connectivity with a simple ping/pong tool.
- List all functions for the authenticated MicroFn user.
- Execute functions in a workspace with a JSON payload.
- Create, rename, and update function code.
- Manage npm packages (list, install, update, remove).
- Manage secrets for functions (create, list, delete).
- Check the latest deployment status for a function.

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name MicroFn MCP Server (Python)
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Ensure Python 3.8+, FastMCP, and a valid MICROFN_API_TOKEN environment variable are set. Install dependencies with pip install -r requirements.txt, then start the server via python my_server.py or using the FastMCP CLI. Add the provided JSON configuration to your MCP settings to integrate the server as a tool provider.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "microfn mcp server (python)": {
            "mcp-server-microfn": {
                "command": "python",
                "args": [
                    "my_server.py"
                ]
            }
        }
    }
}

McpServers

{
    "mcp-server-microfn": {
        "command": "python",
        "args": [
            "my_server.py"
        ]
    }
}

MicroFn MCP Server (Python)

This is a FastMCP server for the MicroFn project. It exposes MCP tools for integration and automation.

---

Features

- Ping tool: Test the server with a simple ping/pong.
- list_functions tool: Lists all functions for the authenticated user via the MicroFn API.
- execute_function tool: Executes the main function in a specified workspace using the /run/{workspace_id} endpoint with a JSON body.

---

Getting Started

Prerequisites

- Python 3.8+
- FastMCP (see below)
- A valid MicroFn API token (set as the MICROFN_API_TOKEN environment variable)

Install dependencies

pip install -r requirements.txt

Run the server

Set your MicroFn API token in the environment:

export MICROFN_API_TOKEN=your_microfn_api_token_here
python my_server.py

Or, using FastMCP CLI (if installed globally):

fastmcp run my_server.py:mcp

Or, to run locally with uvx and FastMCP dev mode:

uvx fastmcp dev server.py

---

MCP Integration Example

To use this server as an MCP tool provider, add the following to your MCP settings:

  "microfn-mcp": {
    "command": "uvx",
    "args": [
      "--from",
      "git+https://github.com/microfnhq/mcp-server-microfn",
      "server"
    ],
    "env": {
      "MICROFN_API_TOKEN": "<token>"
    }
  }

Replace the token values with your own as needed.

---

Usage

The server exposes the following tools:

- ping: Returns "pong".
- list_functions: Returns a list of all functions for the authenticated user (requires MICROFN_API_TOKEN to be set).
- execute_function: Executes the main function in the specified workspace using the /run/{workspace_id} endpoint.

- Arguments:
- function_id (str): Function ID.
- input_data (dict): JSON payload to send.
- Returns: The response from the run endpoint.

- create_function: Creates a new function (workspace) with the given name and code.

- Arguments:
- name (str): Name for the function/workspace.
- code (str): Initial code for the function.
- Returns: The created workspace object.

Example:

  // Create a simple function that returns the sum of two numbers
const code =
export default async function main(input) {
return input.a + input.b;
}
;
const result = await mcp.create_function({ name: "Adder", code });

Advanced Example (calling another function):

  // Suppose you want to create a function that calls another function by ID
import fn from "@microfn/fn";
const targetFunctionId = "e6a08dec-2206-46fa-bbe0-d760124b57ab";
const code =
import fn from "@microfn/fn";
export default async function main(input) {
// Call another function by its ID
const result = await fn.executeFunction("${targetFunctionId}", input);
return result;
}
;
const result = await mcp.create_function({ name: "ProxyCaller", code });

- get_function_code: Gets the code for a function (workspace).

- Arguments:
- function_id (str): Function ID.
- Returns: The code for the workspace.

- update_function_code: Updates the code for a function (workspace).

- Arguments:
- function_id (str): Function ID.
- code (str): The new code to set.
- Returns: The response from the update endpoint.

Example:

  // Update a function to log its input and return it
const code =
export default async function main(input) {
console.log("Received input:", input);
return input;
}
;
await mcp.update_function_code({ function_id: "abc123", code });

Advanced Example (cross-function invocation):

  // Update a function to call another function and process its result
import fn from "@microfn/fn";
const targetFunctionId = "e6a08dec-2206-46fa-bbe0-d760124b57ab";
const code =
import fn from "@microfn/fn";
export default async function main(input) {
// Call another function and add 10 to its result
const result = await fn.executeFunction("${targetFunctionId}", input);
return result + 10;
}
;
await mcp.update_function_code({ function_id: "abc123", code });

- check_deployment: Gets the latest deployment for a function (workspace).
- Arguments:
- function_id (str): Function ID.
- Returns: The latest deployment object.

- get_secrets: Retrieves all secrets for the specified function (workspace).
- Arguments:
- workspace_id (str): The function (workspace) ID.
- Returns: List of secret objects for the function.

- create_secret: Creates a new secret for the specified function (workspace).
- Note: Secrets cannot be overwritten. If a secret with the same key already exists, you must delete it first before creating a new one with the same key.
- Arguments:
- workspace_id (str): The function (workspace) ID.
- key (str): The secret key.
- value (str): The secret value.
- Returns: List of secret objects after creation.
- How to retrieve secrets in your function code:

    import secret from "@microfn/secret";
const url = await secret.getRequired("DISCORD_WEBHOOK_URL");

- delete_secret: Deletes a secret from the specified function (workspace).
- Arguments:
- workspace_id (str): The function (workspace) ID.
- secret_id (str): The secret ID.
- Returns: Empty dict on success.

- rename_function: Renames a function (workspace) by its ID.
- Arguments:
- function_id (str): The ID of the function (workspace) to rename.
- new_name (str): The new name for the function (workspace).
- Returns: The updated workspace object.

Example:

  // Rename a function (workspace) by ID
const result = await mcp.rename_function({ function_id: "abc123", new_name: "MyRenamedFunction" });

- list_packages: Lists all npm packages installed for a function.
- Arguments:
- function_id (str): Function ID to list packages for.
- Returns: List of package objects with name and version.

Example:

  // List all packages for a function
const packages = await mcp.list_packages({ function_id: "abc123" });
// Result: [{ "name": "lodash", "version": "4.17.21" }, ...]

- install_package: Installs an npm package for a function.
- Arguments:
- function_id (str): Function ID to install the package for.
- name (str): Package name to install.
- version (str): Package version to install.
- Returns: The installed package object.

Example:

  // Install a package for a function
const result = await mcp.install_package({
function_id: "abc123",
name: "axios",
version: "1.6.2"
});

- update_package: Updates an npm package version for a function.
- Arguments:
- function_id (str): Function ID to update the package for.
- name (str): Package name to update.
- version (str): New package version.
- Returns: The updated package object.

Example:

  // Update a package version
const result = await mcp.update_package({
function_id: "abc123",
name: "axios",
version: "1.7.0"
});

- remove_package: Removes an npm package from a function.
- Arguments:
- function_id (str): Function ID to remove the package from.
- name (str): Package name to remove.
- Returns: Success response.

Example:

  // Remove a package from a function
const result = await mcp.remove_package({
function_id: "abc123",
name: "axios"
});

- update_package_layer: Updates the Lambda layer with the function's packages.
- Arguments:
- function_id (str): Function ID to update the package layer for.
- Returns: Success response.

Example:

  // Update the package layer for a function
const result = await mcp.update_package_layer({ function_id: "abc123" });

You can test these with a FastMCP client or by sending a tool call via stdio.

---

Project Structure

- my_server.py — Main entry point, defines the MCP server and tools.

---

License

MIT

---

Slay your automations with MicroFn + MCP 🛹

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.