Cover image
Try Now
2025-04-14

小型企业的模型上下文协议服务器

3 years

Works with Finder

0

Github Watches

0

Github Forks

0

Github Stars

Small Business MCP Server

MIT License Python Version MCP SDK

A Model Context Protocol (MCP) server that connects language models with small business data systems. This server implements the MCP paradigm to create a structured, context-aware interface between LLMs and business information, providing tools for data manipulation, contextual resources, and interactive prompt templates.

MCP Primitives

This server implements all three core MCP primitives:

Primitive Control Description Implementation
Tools Model-controlled Functions for LLMs to take actions on data Document processing, data queries
Resources Application-controlled Contextual data for LLM context Business documents, database schema
Prompts User-controlled Interactive templates for common operations Report generation, data analysis

Features

  • Structured Model Context

    • Exposes business data through MCP resources
    • Provides contextual information to improve model reasoning
    • Maintains consistent representation of business concepts
    • Enables precise knowledge retrieval
  • AI-Powered Operations

    • Model-controlled tools for data manipulation
    • File content extraction and categorization
    • Automated relationship mapping between entities
    • Version-controlled document management
  • Interactive Business Intelligence

    • Natural language querying of business data
    • Templated prompts for common business tasks
    • Customizable report generation
    • Contextual analysis of business metrics

Requirements

  • Python 3.8+
  • PostgreSQL 12+
  • Required Python packages:
    • mcp (Model Context Protocol SDK)
    • psycopg2 (PostgreSQL adapter)
    • PyPDF2 (PDF processing)
    • Pillow (Image processing)
    • python-magic (File type detection)
    • langchain (NLP processing)

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/small-business-mcp.git
    cd small-business-mcp
    
  2. Create a virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    
  3. Install dependencies:

    pip install -r requirements.txt
    
  4. Set up PostgreSQL:

    # Create database
    createdb small_business_db
    
    # Set environment variables
    export DB_HOST=localhost
    export DB_PORT=5432
    export DB_NAME=small_business_db
    export DB_USER=your_username
    export DB_PASSWORD=your_password
    

Usage

The MCP server acts as a bridge between language models and your business systems, structured around the three core MCP primitives (tools, resources, and prompts). This architecture allows LLMs to:

  1. Retrieve contextual information about your business via resources
  2. Take actions on your business data via tools
  3. Leverage specialized templates for common tasks via prompts

Starting the Server

You can start the MCP server using either of these methods:

# Method 1: Direct Python execution
python -m MCPServer.server

# Method 2: Using MCP CLI
mcp run MCPServer/server/server.py

The server uses FastMCP to expose tools, resources, and prompts to LLMs.

Connecting with a Client

Connect to the server using the MCP client SDK:

import asyncio
from mcp import ClientSession, StdioServerParameters

async def main():
    # Create server parameters for connecting to the MCP server
    server_params = StdioServerParameters(
        command="python",
        args=["-m", "MCPServer.server"],
        env=None,  # Optional environment variables
    )
    
    async with ClientSession(server_params) as session:
        # Initialize connection
        await session.initialize()
        
        # List available tools
        tools = await session.list_tools()
        print(f"Available tools: {[tool.name for tool in tools]}")
        
        # Process a directory
        result = await session.call_tool(
            "process_business_directory",
            arguments={"directory_path": "/path/to/business/files"}
        )
        print(f"Directory processing result: {result}")
        
        # Query business data
        query_result = await session.call_tool(
            "query_business_data",
            arguments={"query": "Show me all PDF documents from 2023"}
        )
        print(f"Query result: {query_result}")

if __name__ == "__main__":
    asyncio.run(main())

Mounting to an Existing ASGI Server

You can integrate the MCP server with existing ASGI applications:

from starlette.applications import Starlette
from starlette.routing import Mount
from MCPServer.server.server import mcp  # Import the FastMCP instance

# Mount the MCP server to an existing ASGI server
app = Starlette(
    routes=[
        Mount('/mcp', app=mcp.sse_app()),
    ]
)

Available MCP Primitives

MCP defines a structured way for LLMs to interact with external systems through three core primitives, each with a distinct control model and purpose. This server implements:

Tools

Models can use these tools to interact with business data:

  • process_business_directory: Import and organize files from a directory
  • analyze_document: Process a specific document and extract its content/metadata
  • query_business_data: Natural language query interface for business data
  • store_chat_history: Record conversation history in the database
  • create_business_report: Generate reports based on stored data

Resources

Resources provide contextual information to LLMs, exposing data that helps models reason about business objects. Unlike tools, resources are passively accessed rather than executed:

  • schema://database: Database schema for reasoning about data structure
  • doc://{document_id}: Access to specific document content
  • stats://business: Business statistics and metrics

Prompts

Prompts are user-controlled templates that guide how LLMs approach specific tasks, providing a standardized way to frame common business operations:

  • generate_report: Template for creating various business reports
  • analyze_data: Template for analyzing business data patterns
  • setup_assistant: Template for configuring a business data assistant

Server Capabilities

The server declares these capabilities during initialization:

Capability Feature Flag Description
tools listChanged Business data tools
resources subscribelistChanged Document and schema access
prompts listChanged Business report templates
logging - Server logging configuration
completion - Argument completion suggestions

Security

  • All database credentials and API keys are managed through environment variables
  • File access is restricted to specified directories
  • Data encryption for sensitive information
  • Regular backup procedures

Contributing

Contributions are welcome! Please read our Contributing Guidelines for details.

License

This project is licensed under the MIT License - see the LICENSE file for details.

相关推荐

  • av
  • 毫不费力地使用一个命令运行LLM后端,API,前端和服务。

  • 1Panel-dev
  • 🔥1Panel提供了直观的Web接口和MCP服务器,用于在Linux服务器上管理网站,文件,容器,数据库和LLMS。

  • WangRongsheng
  • 🧑‍🚀 llm 资料总结(数据处理、模型训练、模型部署、 o1 模型、mcp 、小语言模型、视觉语言模型)|摘要世界上最好的LLM资源。

  • sigoden
  • 使用普通的bash/javascript/python函数轻松创建LLM工具和代理。

  • hkr04
  • 轻巧的C ++ MCP(模型上下文协议)SDK

  • rulego
  • ⛓️Rulego是一种轻巧,高性能,嵌入式,下一代组件编排规则引擎框架。

  • RockChinQ
  • 😎简单易用、🧩丰富生态 -大模型原生即时通信机器人平台| 适配QQ / 微信(企业微信、个人微信) /飞书 /钉钉 / discord / telegram / slack等平台| 支持chatgpt,deepseek,dify,claude,基于LLM的即时消息机器人平台,支持Discord,Telegram,微信,Lark,Dingtalk,QQ,Slack

  • dmayboroda
  • 带有可配置容器的本地对话抹布

  • paulwing
  • 使用MCP服务创建的测试存储库

  • modelscope
  • 开始以更轻松的方式开始构建具有LLM授权的多代理应用程序。

    Reviews

    2.7 (12)
    Avatar
    user_SZGDeqW7
    2025-04-23

    As a dedicated user of small-business-mcp by Joe Spencer, I can confidently say this tool has been indispensable for my small business. Its intuitive interface and comprehensive features have streamlined our operations, making our workflow more efficient. Whether you're managing finances, tracking sales, or organizing tasks, this application covers it all. Highly recommended for anyone looking to enhance their business productivity!

    Avatar
    user_I2dBqcXV
    2025-04-23

    Small-business-mcp by Joe-Spencer is a game-changer for small business owners. The application is user-friendly and incredibly efficient, helping streamline operations and manage tasks effortlessly. It's clear that a lot of thought and expertise went into its development. Highly recommend for anyone looking to boost productivity and organization in their small business!

    Avatar
    user_uvgWRpe1
    2025-04-23

    I've been using the small-business-mcp, created by Joe Spencer, for a few weeks now, and it has completely transformed how I operate my small business. The user-friendly interface and comprehensive features are incredibly helpful. Best tool for small businesses looking to streamline their operations! Highly recommend!

    Avatar
    user_wKfQXU6V
    2025-04-23

    As a loyal user of small-business-mcp, I can confidently say that this product has revolutionized my business operations. Joe Spencer has done an incredible job in creating a tool that is both intuitive and highly effective. The interface is user-friendly, and the features cater perfectly to small business needs, making management easier and more efficient. Highly recommended!

    Avatar
    user_N2wQf9Ko
    2025-04-23

    I've been using the small-business-mcp by Joe-Spencer and it's a fantastic tool for managing my small business. It simplifies complex processes and has increased my productivity. Highly recommend it for any small business owner looking for efficient management solutions!

    Avatar
    user_iNDDHTQb
    2025-04-23

    As a dedicated user of the small-business-mcp by Joe-Spencer, I can confidently say it's a game-changer for managing small business operations. The tool is user-friendly, efficient, and seamlessly integrates into our daily workflow. Its intuitive interface and comprehensive features have significantly streamlined our processes, saving us time and effort. Highly recommended for any small business owner!

    Avatar
    user_JeBz87FJ
    2025-04-23

    As a devoted user of the Small-Business-MCP by Joe Spencer, I can confidently say that this tool has significantly streamlined our business processes. It's intuitive and user-friendly, making it accessible for all team members. The efficiency and productivity in our small business have noticeably increased since adopting this application. Highly recommended!

    Avatar
    user_f9qwr3rx
    2025-04-23

    As a dedicated user of small-business-mcp by Joe-Spencer, I find it incredibly useful for managing and optimizing my business operations. The comprehensive features and user-friendly interface have simplified many of our processes, allowing us to focus more on growth and customer satisfaction. It's an essential tool for any small business owner looking to streamline their management activities effectively. Highly recommend!

    Avatar
    user_YkJ3CVNH
    2025-04-23

    As a loyal user of the small-business-mcp, I must say Joe-Spencer has done an incredible job. This tool has revolutionized the way I manage my small business operations. It's user-friendly, efficient, and has significantly improved our productivity. I highly recommend it to fellow entrepreneurs looking to streamline their processes.

    Avatar
    user_5k88dU4m
    2025-04-23

    As a dedicated user of the small-business-mcp, I can confidently say that Joe-Spencer has crafted a phenomenal product. It's incredibly user-friendly and has significantly streamlined our business processes. The seamless integration and comprehensive features have truly enhanced our efficiency and productivity. Highly recommend it to any small business looking for reliable and effective management solutions!

    Avatar
    user_3MEw5QPx
    2025-04-23

    As a dedicated user of small-business-mcp by Joe Spencer, I can confidently say this tool has transformed the way I manage my business operations. It's user-friendly, efficient, and incredibly reliable. The support from the creator is top-notch, and the continuous updates make it even better. Highly recommend for any small business owner!

    Avatar
    user_uCASR1j2
    2025-04-23

    As a devoted user of small-business-mcp, I must say it has transformed the way I manage my business operations. Created by Joe-Spencer, this resource is incredibly user-friendly and efficient, perfect for small businesses. Its seamless integration and powerful features help streamline my workflow, making everyday tasks a breeze. Highly recommended for any small business owner looking to enhance productivity!