Development GuideΒΆ

This guide covers how to set up a development environment and contribute to Shepherd MCP.

SetupΒΆ

Clone the repository:

git clone https://github.com/neuralis/shepherd-mcp
cd shepherd-mcp

Create a virtual environment and install dependencies:

python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -e ".[dev]"

Running TestsΒΆ

Run the test suite with pytest:

pytest

Run with coverage:

pytest --cov=shepherd_mcp

Running LocallyΒΆ

Set up your environment variables:

export AIOBS_API_KEY=aiobs_sk_xxxx
export LANGFUSE_PUBLIC_KEY=pk-lf-xxxx
export LANGFUSE_SECRET_KEY=sk-lf-xxxx

Run the MCP server:

python -m shepherd_mcp

Code StyleΒΆ

This project uses ruff for linting and formatting:

# Check for issues
ruff check .

# Auto-fix issues
ruff check --fix .

# Format code
ruff format .

Project StructureΒΆ

src/shepherd_mcp/
β”œβ”€β”€ __init__.py          # Package exports
β”œβ”€β”€ __main__.py          # Entry point
β”œβ”€β”€ server.py            # MCP server with tool handlers
β”œβ”€β”€ models/              # Data models
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ aiobs.py         # AIOBS-specific models
β”‚   └── langfuse.py      # Langfuse-specific models
└── providers/           # Provider clients
    β”œβ”€β”€ __init__.py
    β”œβ”€β”€ base.py          # Base provider interface
    β”œβ”€β”€ aiobs.py         # AIOBS client implementation
    └── langfuse.py      # Langfuse client implementation

ArchitectureΒΆ

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     stdio      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Cursor/Claude  β”‚ ◄────────────► β”‚  shepherd-mcp   β”‚
β”‚    (Client)     β”‚   stdin/stdout β”‚   (subprocess)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                            β”‚ HTTPS
                                  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                  β”‚                   β”‚
                                  β–Ό                   β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚ Shepherd APIβ”‚     β”‚ Langfuse APIβ”‚
                         β”‚   (AIOBS)   β”‚     β”‚   (Cloud)   β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Building DocumentationΒΆ

Build the Sphinx documentation:

cd docs
make html

The built documentation will be in docs/_build/html/.

Publishing to PyPIΒΆ

Releases are automatically published to PyPI via GitHub Actions when a release is created.

To publish manually:

# Build the package
pip install build twine
python -m build

# Upload to PyPI
twine upload dist/*

Adding a New ProviderΒΆ

To add support for a new observability provider:

  1. Create a new models file in src/shepherd_mcp/models/ with your data models

  2. Create a new provider client in src/shepherd_mcp/providers/ inheriting from BaseProvider

  3. Add tool definitions in server.py under list_tools()

  4. Add tool handlers in server.py under call_tool()

  5. Update the provider exports in providers/__init__.py

  6. Add tests in tests/

Example provider skeleton:

from shepherd_mcp.providers.base import BaseProvider, AuthenticationError

class MyProvider(BaseProvider):
    def __init__(self, api_key: str | None = None):
        self.api_key = api_key or os.environ.get("MY_PROVIDER_API_KEY")
        if not self.api_key:
            raise AuthenticationError("No API key provided")
        # Initialize HTTP client, etc.

    @property
    def name(self) -> str:
        return "my_provider"

    def list_sessions(self):
        # Implement session listing
        pass

    def close(self) -> None:
        # Clean up resources
        pass

ContributingΒΆ

  1. Fork the repository

  2. Create a feature branch: git checkout -b feature/my-feature

  3. Make your changes

  4. Run tests: pytest

  5. Run linting: ruff check .

  6. Commit your changes: git commit -am 'Add my feature'

  7. Push to the branch: git push origin feature/my-feature

  8. Create a Pull Request