Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.PHONY: ensure-scripts-exec setup test

ensure-scripts-exec:
@chmod +x scripts/* || true

setup: ensure-scripts-exec
@scripts/setup_uv.sh

test:
@uv run $(DEBUGPY_ARGS) -m pytest tests
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,39 @@ dependencies = [
Then run:

```bash
uv venv
source .venv/bin/activate
uv sync
```

## Dev Setup

Use the `Makefile` target to ensure `uv` is installed, and your virtual environment is active and sync'd.

```bash
make setup
```

## Testing

Ensure you have the correct dependencies installed for testing:

```bash
uv sync --group tests
```

Then to run all tests:

```bash
uv run pytest tests
```

... or via `Makefile`:

```bash
make test
```

## Quick Start

```python
Expand Down
10 changes: 5 additions & 5 deletions examples/readme_maker/readme_maker.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
If a template README file from an original repository ({input_repo_readme}) is provided:

- Template Utilization: Use the structure and style of the original README file as a guide.
- Content Adaptation: Modify the content to accurately describe the target repository.
This step requires analyzing the entire codebase of the target repository ({target_repo})
- Content Adaptation: Modify the content to accurately describe the target repository.
This step requires analyzing the entire codebase of the target repository ({target_repo})
to understand its functionality, features, and any other relevant details that should be included in the README.

If no template README file is provided:
Expand All @@ -45,7 +45,7 @@
-License information
-Acknowledgements (if applicable)

To create the README, analyze the entire codebase of the target repository ({target_repo})
To create the README, analyze the entire codebase of the target repository ({target_repo})
to understand its functionality, features, and any other relevant details.

After creating the new README file:
Expand All @@ -55,8 +55,8 @@
commit message that clearly indicates the addition of the new README.
3. Pull Request (PR) Creation: Open a Pull Request against the main branch of the target
repository, including the new README file.
4. PR Description: In the Pull Request description, mention that the README was generated
by an AI agent of the model {agent_model}. If a template was used, include a link to
4. PR Description: In the Pull Request description, mention that the README was generated
by an AI agent of the model {agent_model}. If a template was used, include a link to
the original README template ({input_repo_readme}) used for generating the new README.

When providing code snippets for this task, follow the guidelines for code modifications:
Expand Down
16 changes: 15 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "mcpd-sdk"
version = "0.0.1"
dynamic = ["version"]
description = "mcpd Python SDK"
readme = "README.md"
license = {text = "Apache-2.0"}
Expand All @@ -23,6 +23,8 @@ lint = [

tests = [
"pytest>=8.3.5",
"setuptools>=80.9.0",
"setuptools-scm[toml]>=8.3.1",
]

all = [
Expand All @@ -31,6 +33,18 @@ all = [
{ include-group = "tests" },
]

[build-system]
requires = ["setuptools>=48", "setuptools_scm[toml]>=6.3.1"]
build-backend = "setuptools.build_meta"

[tool.setuptools.packages.find]
exclude = ["tests", "tests.*"]
where = ["src"]
namespaces = false

[tool.setuptools.package-data]
"*" = ["py.typed"]

[tool.ruff]
fix = true
line-length=120
Expand Down
50 changes: 50 additions & 0 deletions scripts/setup_uv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'

# ##########
# Install UV
# ##########

# Expected installation path for uv
# See: https://docs.astral.sh/uv/configuration/installer/#changing-the-install-path
LOCAL_BIN="${LOCAL_BIN:-$HOME/.local/bin}"

# Ensure LOCAL_BIN exists and is on PATH
mkdir -p "$LOCAL_BIN"
if [[ ":$PATH:" != *":$LOCAL_BIN:"* ]]; then
export PATH="$LOCAL_BIN:$PATH"
fi

VENV_DIR=".venv"

# Install or update uv
if ! command -v uv &>/dev/null; then
echo "uv not found – installing to $LOCAL_BIN"
curl -fsSL https://astral.sh/uv/install.sh | UV_INSTALL_DIR="$LOCAL_BIN" sh
else
current=$(uv --version | awk '{print $2}')
echo "Found uv v$current"
if command -v jq &>/dev/null; then
latest=$(curl -fsS https://api.github.com/repos/astral-sh/uv/releases/latest \
| jq -r .tag_name)
if [[ "$current" != "$latest" ]]; then
echo "Updating uv: $current → $latest"
uv self update
fi
fi
fi

# Bootstrap root .venv
echo "Bootstrapping root .venv in folder $VENV_DIR"
uv venv "$VENV_DIR"
uv sync --group all --active

echo "Done! Root environment is ready in: $VENV_DIR"

# After detecting PATH lacked LOCAL_BIN…
if [[ ":$PATH:" != *":$LOCAL_BIN:"* ]]; then
echo "Note: added $LOCAL_BIN to PATH for this session."
echo "To make it permanent, add to your shell profile:"
echo " export PATH=\"$LOCAL_BIN:\$PATH\""
fi
15 changes: 15 additions & 0 deletions src/mcpd_sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
from importlib.metadata import PackageNotFoundError, version

from .mcpd_client import McpdClient, McpdError

try:
__version__ = version("mcpd_sdk")
except PackageNotFoundError:
# In the case of local development
# i.e., running directly from the source directory without package being installed
__version__ = "0.0.0-dev"

__all__ = [
"McpdClient",
"McpdError",
"__version__",
]
Empty file added src/mcpd_sdk/py.typed
Empty file.
Empty file added tests/__init__.py
Empty file.
57 changes: 57 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
from unittest.mock import Mock

import pytest

from mcpd_sdk import McpdClient, McpdError


@pytest.fixture(scope="function")
def mock_client():
client = Mock()
client._perform_call = Mock(return_value={"result": "success"})
client.has_tool = Mock(return_value=True)
return client


@pytest.fixture(scope="function")
def mock_response():
response = Mock()
response.json.return_value = {"result": "success"}
response.raise_for_status.return_value = None
return response


@pytest.fixture(scope="session")
def basic_schema():
return {
"name": "test_tool",
"description": "A test tool",
"inputSchema": {
"type": "object",
"properties": {
"param1": {"type": "string", "description": "First parameter"},
"param2": {"type": "integer", "description": "Second parameter"},
},
"required": ["param1"],
},
}


@pytest.fixture(scope="session")
def fqdn() -> str:
return "http://localhost:8090"


@pytest.fixture(scope="session")
def api_url(fqdn) -> str:
return fqdn + "/api/v1"


@pytest.fixture(scope="function")
def client(fqdn):
return McpdClient(api_endpoint=fqdn)


@pytest.fixture(scope="function")
def client_with_auth(fqdn):
return McpdClient(api_endpoint=fqdn, api_key="test-key") # pragma: allowlist secret
Empty file added tests/unit/__init__.py
Empty file.
Loading