Skip to main content

FlowLLM: Simplifying LLM-based HTTP/MCP Service Development

Project description

FlowLLM Logo

FlowLLM: Simplifying LLM-based HTTP/MCP Service Development
If you find it useful, please give us a ⭐ Star. Your support drives our continuous improvement.

Python Version PyPI Version License GitHub Stars

English | 简体中文


📖 Introduction

FlowLLM encapsulates LLM, Embedding, and vector_store capabilities as HTTP/MCP services. It is suitable for AI assistants, RAG applications, and workflow services, and can be integrated into MCP-compatible client tools.

🏗️ Architecture Overview

FlowLLM Framework

🌟 Applications Based on FlowLLM

Project Name Description
ReMe Memory management toolkit for agents

📢 Recent Updates

Date Update Content
2025-11-15 Added File Tool Op feature with 13 file operation tools, supporting file reading, writing, editing, searching, directory operations, system command execution, and task management
2025-11-14 Added Token counting capability, supporting accurate calculation of token counts for messages and tools via self.token_count() method, with support for multiple backends (base, openai, hf). See configuration examples in default.yaml

📚 Learning Resources

Project developers will share their latest learning materials here.

Date Title Description
2025-11-14 HaluMem Analysis HaluMem: Evaluating Hallucinations in Memory Systems of Agents Analysis
2025-11-13 Gemini CLI Context Management Mechanism Multi-layer Context Management Strategy for Gemini CLI
2025-11-10 Context Management Guide Context Management Guide
2025-11-10 LangChain&Manus Video Materials LangChain & Manus Context Management Video

⭐ Core Features

  • Simple Op Development: Inherit from BaseOp or BaseAsyncOp and implement your business logic. FlowLLM provides lazy-initialized LLM, Embedding models, and vector stores accessible via self.llm, self.embedding_model, and self.vector_store. It also offers prompt template management through prompt_format() and get_prompt() methods. Additionally, FlowLLM includes built-in token counting capabilities. Use self.token_count() to accurately calculate token counts for messages and tools, supporting multiple backends (base, openai, hf, etc.).

  • Flexible Flow Orchestration: Compose Ops into Flows via YAML configuration. >> denotes serial composition; | denotes parallel composition. For example, SearchOp() >> (AnalyzeOp() | TranslateOp()) >> FormatOp() builds complex workflows. Define input/output schemas and start the service with flowllm config=your_config.

  • Automatic Service Generation: FlowLLM automatically generates HTTP, MCP, and CMD services. The HTTP service provides RESTful APIs with synchronous JSON and HTTP Stream responses. The MCP service registers as Model Context Protocol tools for MCP-compatible clients. The CMD service executes a single Op in command-line mode for quick testing and debugging.


⚡ Quick Start

📦 Step0 Installation

📥 From PyPI

pip install flowllm

🔧 From Source

git clone https://github.com/flowllm-ai/flowllm.git
cd flowllm
pip install -e .

For detailed installation and configuration, refer to the Installation Guide.

⚙️ Configuration

Create a .env file and configure your API keys. Copy from example.env and modify:

cp example.env .env

Configure your API keys in the .env file:

FLOW_LLM_API_KEY=sk-xxxx
FLOW_LLM_BASE_URL=https://xxxx/v1
FLOW_EMBEDDING_API_KEY=sk-xxxx
FLOW_EMBEDDING_BASE_URL=https://xxxx/v1

For detailed configuration, refer to the Configuration Guide.

🛠️ Step1 Build Op

from flowllm.core.context import C
from flowllm.core.op import BaseAsyncOp
from flowllm.core.schema import Message
from flowllm.core.enumeration import Role

@C.register_op()
class SimpleChatOp(BaseAsyncOp):
    async def async_execute(self):
        query = self.context.get("query", "")
        messages = [Message(role=Role.USER, content=query)]

        # Use token_count method to calculate token count
        token_num = self.token_count(messages)
        print(f"Input tokens: {token_num}")

        response = await self.llm.achat(messages=messages)
        self.context.response.answer = response.content.strip()

For details, refer to the Simple Op Guide, LLM Op Guide, and Advanced Op Guide (including Embedding, VectorStore, and concurrent execution).

📝 Step2 Configure Config

The following example demonstrates building an MCP (Model Context Protocol) service. Create a configuration file my_mcp_config.yaml:

backend: mcp

mcp:
  transport: sse
  host: "0.0.0.0"
  port: 8001

flow:
  demo_mcp_flow:
    flow_content: MockSearchOp()
    description: "Search results for a given query."
    input_schema:
      query:
        type: string
        description: "User query"
        required: true

llm:
  default:
    backend: openai_compatible
    model_name: qwen3-30b-a3b-instruct-2507
    params:
      temperature: 0.6
    token_count: # Optional, configure token counting backend
      model_name: Qwen/Qwen3-30B-A3B-Instruct-2507
      backend: hf  # Supports base, openai, hf, etc.
      params:
        use_mirror: true

🚀 Step3 Start MCP Service

flowllm \
  config=my_mcp_config \
  backend=mcp \  # Optional, overrides config
  mcp.transport=sse \  # Optional, overrides config
  mcp.port=8001 \  # Optional, overrides config
  llm.default.model_name=qwen3-30b-a3b-thinking-2507  # Optional, overrides config

After the service starts, refer to the Client Guide to use the service and obtain the tool_call required by the model.


📚 Detailed Documentation

🚀 Getting Started

🔧 Op Development

🔀 Flow Orchestration

🌐 Service Usage


🤝 Contributing

Contributions of all forms are welcome! For participation methods, refer to the Contribution Guide.


📄 License

This project is licensed under the Apache 2.0 license.


Star 历史

Star History Chart


GitHubDocumentationPyPI

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

flowllm-0.2.0.3.tar.gz (173.4 kB view details)

Uploaded Source

Built Distribution

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

flowllm-0.2.0.3-py3-none-any.whl (215.9 kB view details)

Uploaded Python 3

File details

Details for the file flowllm-0.2.0.3.tar.gz.

File metadata

  • Download URL: flowllm-0.2.0.3.tar.gz
  • Upload date:
  • Size: 173.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for flowllm-0.2.0.3.tar.gz
Algorithm Hash digest
SHA256 a85ff3725040589e733c997b0bbd0e34b4c6039751c9b8ae9d46ac52d21b33bf
MD5 39386bd1bcf488c04036e293498dd9fe
BLAKE2b-256 a7f81aeea825da30539f1f80671bd2fd28a2e3486f52937ded74e7892ea06de4

See more details on using hashes here.

File details

Details for the file flowllm-0.2.0.3-py3-none-any.whl.

File metadata

  • Download URL: flowllm-0.2.0.3-py3-none-any.whl
  • Upload date:
  • Size: 215.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for flowllm-0.2.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d98ae87795b8cb1017d90b187e88fc8418941fd2cef1309d0429e8ef04541a81
MD5 e929127bb99c782ce38b168f1fe9392a
BLAKE2b-256 335f811007bd0ebeeabec433669f7eca8edbe129f92ceb30f504cb34e11a8ac3

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