Metadata-Version: 2.4
Name: mcp-server-llmling
Version: 1.0.1
Summary: MCP (Model Context Protocol) server for resources, prompts and tools defined in LLMling YAML configs
Keywords: ai,fastmcp,llm,llmling,mcp,model-context-protocol,prompts,server,tools,yaml
Author: Philipp Temminghoff
Author-email: Philipp Temminghoff <philipptemminghoff@googlemail.com>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: FastAPI
Classifier: Framework :: Pydantic
Classifier: Framework :: Pydantic :: 2
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development
Classifier: Topic :: Utilities
Classifier: Typing :: Typed
Requires-Dist: anyenv>=0.5.0
Requires-Dist: fastapi[standard]>=0.115.6
Requires-Dist: fastmcp>=3.0.0,<4
Requires-Dist: httpx>=0.27.0
Requires-Dist: llmling>=1.0.0
Requires-Dist: logfire[fastapi]>=2.6.2
Requires-Dist: mcp>=1.1.0,<2
Requires-Dist: pydantic
Requires-Dist: schemez>=1.0.0
Requires-Dist: typer>=0.12.0
Requires-Dist: universal-pathlib>=0.2.5
Requires-Dist: upathtools[httpx]
Requires-Dist: uvicorn
Requires-Dist: websockets>=14.1
Requires-Dist: nicegui ; extra == 'gui'
Requires-Python: >=3.13
Project-URL: Code coverage, https://app.codecov.io/gh/phil65/mcp-server-llmling
Project-URL: Documentation, https://phil65.github.io/mcp-server-llmling/
Project-URL: Homepage, https://phil65.github.io/mcp-server-llmling/
Project-URL: Issues, https://github.com/phil65/mcp-server-llmling/issues
Project-URL: Source, https://github.com/phil65/mcp-server-llmling
Provides-Extra: gui
Description-Content-Type: text/markdown

# mcp-server-llmling

[![PyPI License](https://img.shields.io/pypi/l/mcp-server-llmling.svg)](https://pypi.org/project/mcp-server-llmling/)
[![Package status](https://img.shields.io/pypi/status/mcp-server-llmling.svg)](https://pypi.org/project/mcp-server-llmling/)
[![Monthly downloads](https://img.shields.io/pypi/dm/mcp-server-llmling.svg)](https://pypi.org/project/mcp-server-llmling/)
[![Distribution format](https://img.shields.io/pypi/format/mcp-server-llmling.svg)](https://pypi.org/project/mcp-server-llmling/)
[![Wheel availability](https://img.shields.io/pypi/wheel/mcp-server-llmling.svg)](https://pypi.org/project/mcp-server-llmling/)
[![Python version](https://img.shields.io/pypi/pyversions/mcp-server-llmling.svg)](https://pypi.org/project/mcp-server-llmling/)
[![Implementation](https://img.shields.io/pypi/implementation/mcp-server-llmling.svg)](https://pypi.org/project/mcp-server-llmling/)
[![Releases](https://img.shields.io/github/downloads/phil65/mcp-server-llmling/total.svg)](https://github.com/phil65/mcp-server-llmling/releases)
[![Github Contributors](https://img.shields.io/github/contributors/phil65/mcp-server-llmling)](https://github.com/phil65/mcp-server-llmling/graphs/contributors)
[![Github Forks](https://img.shields.io/github/forks/phil65/mcp-server-llmling)](https://github.com/phil65/mcp-server-llmling/forks)
[![Github Issues](https://img.shields.io/github/issues/phil65/mcp-server-llmling)](https://github.com/phil65/mcp-server-llmling/issues)
[![Github Issues](https://img.shields.io/github/issues-pr/phil65/mcp-server-llmling)](https://github.com/phil65/mcp-server-llmling/pulls)
[![Github Watchers](https://img.shields.io/github/watchers/phil65/mcp-server-llmling)](https://github.com/phil65/mcp-server-llmling/watchers)
[![Github Stars](https://img.shields.io/github/stars/phil65/mcp-server-llmling)](https://github.com/phil65/mcp-server-llmling/stars)
[![Github Repository size](https://img.shields.io/github/repo-size/phil65/mcp-server-llmling)](https://github.com/phil65/mcp-server-llmling)
[![Github last commit](https://img.shields.io/github/last-commit/phil65/mcp-server-llmling)](https://github.com/phil65/mcp-server-llmling/commits)
[![Github release date](https://img.shields.io/github/release-date/phil65/mcp-server-llmling)](https://github.com/phil65/mcp-server-llmling/releases)
[![Github language count](https://img.shields.io/github/languages/count/phil65/mcp-server-llmling)](https://github.com/phil65/mcp-server-llmling)
[![Github commits this month](https://img.shields.io/github/commit-activity/m/phil65/mcp-server-llmling)](https://github.com/phil65/mcp-server-llmling)
[![Package status](https://codecov.io/gh/phil65/mcp-server-llmling/branch/main/graph/badge.svg)](https://codecov.io/gh/phil65/mcp-server-llmling/)
[![PyUp](https://pyup.io/repos/github/phil65/mcp-server-llmling/shield.svg)](https://pyup.io/repos/github/phil65/mcp-server-llmling/)

[Read the documentation!](https://phil65.github.io/mcp-server-llmling/)



# mcp-server-llmling

## Overview

mcp-server-llmling is a [Model Context Protocol](https://modelcontextprotocol.io/) (MCP) server
that serves resources, prompts and tools declared in an [LLMling](https://github.com/phil65/LLMling)
YAML configuration file. No code is needed to set up a custom MCP server.

## Installation

```bash
pip install mcp-server-llmling
# or run it directly
uvx mcp-server-llmling start path/to/your/config.yml
```

- **Static Declaration**: Define your LLM's environment in YAML - no code required
- **MCP Protocol**: Built on the Model Context Protocol (MCP) for standardized LLM interaction
- **Component Types**:
  - **Resources**: Content providers (files, text, CLI output, etc.)
  - **Prompts**: Message templates with arguments
  - **Tools**: Python functions callable by the LLM

The YAML configuration creates a complete environment that provides the LLM with:
- Access to content via resources
- Structured prompts for consistent interaction
- Tools for extending capabilities


## Key Features

### 1. Resource Management
- Load and manage different types of resources:
  - Text files (`PathResource`)
  - Raw text content (`TextResource`)
  - CLI command output (`CLIResource`)
  - Python source code (`SourceResource`)
  - Python callable results (`CallableResource`)
  - Git repository content (`RepositoryResource`)
- Support for resource watching/hot-reload
- Resource processing pipelines
- URI-based resource access

### 2. Tool System
- Register and execute Python functions as LLM tools
- Support for OpenAPI-based tools
- Entry point-based tool discovery
- Tool validation and parameter checking
- Structured tool responses

### 3. Prompt Management
- Static prompts with template support
- Dynamic prompts from Python functions
- File-based prompts
- Prompt argument validation
- Completion suggestions for prompt arguments

### 4. Multiple Transport Options
- Stdio-based communication (default)
- Streamable HTTP and Server-Sent Events (SSE) for web clients

### 5. Config injection and Zed mode
- Optional HTTP/WebSocket API to add or update components of a running server
  (`--enable-injection`, `mcp-server-llmling inject config.yml`)
- `--zed-mode` wraps multi-argument prompts for Zed editor compatibility




## Usage

### With Zed Editor

Add LLMLing as a context server in your `settings.json`:

```json
{
  "context_servers": {
    "llmling": {
      "command": {
        "env": {},
        "label": "llmling",
        "path": "uvx",
        "args": [
          "mcp-server-llmling",
          "start",
          "path/to/your/config.yml"
        ]
      },
      "settings": {}
    }
  }
}
```

### With Claude Desktop

Configure LLMLing in your `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "llmling": {
      "command": "uvx",
      "args": [
        "mcp-server-llmling",
        "start",
        "path/to/your/config.yml"
      ],
      "env": {}
    }
  }
}
```

### Manual Server Start

Start the server directly from command line:

```bash
# Latest version, stdio transport
uvx mcp-server-llmling@latest start path/to/your/config.yml

# Streamable HTTP on a custom port
uvx mcp-server-llmling start path/to/your/config.yml --transport streamable-http --port 3001

# Other commands
uvx mcp-server-llmling info
uvx mcp-server-llmling --help
```

### 1. Programmatic usage

```python
import asyncio

from llmling import RuntimeConfig
from mcp_server_llmling import LLMLingServer


async def main() -> None:
    async with RuntimeConfig.open("config.yml") as runtime:
        server = LLMLingServer(runtime, enable_injection=True)
        await server.start()


asyncio.run(main())
```

### 2. Using Custom Transport

```python
import asyncio

from llmling import RuntimeConfig
from mcp_server_llmling import LLMLingServer


async def main() -> None:
    async with RuntimeConfig.open("config.yml") as runtime:
        server = LLMLingServer(
            runtime,
            transport="streamable-http",
            # passed on to FastMCP.run_async()
            transport_options={"host": "localhost", "port": 3001},
        )
        await server.start()


asyncio.run(main())
```

### 3. Resource Configuration

```yaml
resources:
  python_code:
    type: path
    path: "./src/**/*.py"
    watch:
      enabled: true
      patterns:
        - "*.py"
        - "!**/__pycache__/**"

  api_docs:
    type: text
    content: |
      API Documentation
      ================
      ...
```

### 4. Tool Configuration

```yaml
tools:
  analyze_code:
    import_path: "mymodule.tools.analyze_code"
    description: "Analyze Python code structure"

toolsets:
  api:
    type: openapi
    spec: "https://api.example.com/openapi.json"
```


## Server Configuration

The server is configured through a YAML file with the following sections:

```yaml
global_settings:
  timeout: 30
  max_retries: 3
  log_level: "INFO"
  requirements: []
  pip_index_url: null
  extra_paths: []

resources:
  # Resource definitions...

tools:
  # Tool definitions...

toolsets:
  # Toolset definitions...

prompts:
  # Prompt definitions...
```

## MCP Protocol

The server implements the MCP protocol which supports:

1. **Resource Operations**
   - List available resources
   - Read resource content
   - Watch for resource changes

2. **Tool Operations**
   - List available tools
   - Execute tools with parameters
   - Get tool schemas

3. **Prompt Operations**
   - List available prompts
   - Get formatted prompts
   - Get completions for prompt arguments

4. **Notifications**
   - Resource changes
   - Tool/prompt list updates
   - Progress updates
   - Log messages
