Skip to content

Commit

Permalink
Merge pull request modelcontextprotocol#24 from modelcontextprotocol/…
Browse files Browse the repository at this point in the history
…justin/pypi-publish

Python build + publish workflow
  • Loading branch information
jspahrsummers authored Nov 21, 2024
2 parents d10d65f + 23b6159 commit 8851072
Show file tree
Hide file tree
Showing 11 changed files with 177 additions and 28 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Python

on:
push:
branches:
- main
pull_request:
release:
types: [published]

jobs:
detect-packages:
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.find-packages.outputs.packages }}
steps:
- uses: actions/checkout@v4

- name: Find Python packages
id: find-packages
working-directory: src
run: |
PACKAGES=$(find . -name pyproject.toml -exec dirname {} \; | sed 's/^\.\///' | jq -R -s -c 'split("\n")[:-1]')
echo "packages=$PACKAGES" >> $GITHUB_OUTPUT
build:
needs: [detect-packages]
strategy:
matrix:
package: ${{ fromJson(needs.detect-packages.outputs.packages) }}
name: Build ${{ matrix.package }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: "src/${{ matrix.package }}/.python-version"

- name: Install dependencies
working-directory: src/${{ matrix.package }}
run: uv sync --frozen --all-extras --dev

- name: Run pyright
working-directory: src/${{ matrix.package }}
run: uv run --frozen pyright

- name: Build package
working-directory: src/${{ matrix.package }}
run: uv build

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.package }}
path: src/${{ matrix.package }}/dist/

publish:
runs-on: ubuntu-latest
needs: [build, detect-packages]
if: github.event_name == 'release'

strategy:
matrix:
package: ${{ fromJson(needs.detect-packages.outputs.packages) }}
name: Publish ${{ matrix.package }}

environment: release
permissions:
id-token: write # Required for trusted publishing

steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: dist-${{ matrix.package }}
path: dist/

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: TypeScript

on:
push:
branches:
Expand Down
9 changes: 6 additions & 3 deletions src/git/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[project]
name = "mcp-git"
name = "mcp-server-git"
version = "0.2.0"
description = "A Model Context Protocol server providing tools to read, search, and manipulate Git repositories programmatically via LLMs"
readme = "README.md"
Expand All @@ -23,11 +23,14 @@ dependencies = [
]

[project.scripts]
mcp-git = "mcp_git:main"
mcp-server-git = "mcp_server_git:main"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.uv]
dev-dependencies = ["ruff>=0.7.3"]
dev-dependencies = [
"pyright>=1.1.389",
"ruff>=0.7.3",
]
5 changes: 0 additions & 5 deletions src/git/src/mcp_git/__main__.py

This file was deleted.

File renamed without changes.
5 changes: 5 additions & 0 deletions src/git/src/mcp_server_git/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# __main__.py

from mcp_server_git import main

main()
30 changes: 28 additions & 2 deletions src/git/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions src/sqlite/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
[project]
name = "sqlite"
name = "mcp-server-sqlite"
version = "0.1.0"
description = "A simple SQLite MCP server"
readme = "README.md"
requires-python = ">=3.11"
dependencies = [
"mcp>=0.9.1",
]
dependencies = ["mcp>=0.9.1"]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.uv]
dev-dependencies = [
"pyright>=1.1.389",
]

[project.scripts]
sqlite = "sqlite:main"
mcp-server-sqlite = "mcp_server_sqlite:main"
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
from pathlib import Path
from mcp.server.models import InitializationOptions
import mcp.types as types
from mcp.server import NotificationOptions, Server, AnyUrl
from mcp.server import NotificationOptions, Server
import mcp.server.stdio
from pydantic import AnyUrl

# Set up logging to file
log_file = Path('mcp_server.log')
Expand Down Expand Up @@ -332,7 +333,7 @@ async def handle_call_tool(
memo = self._synthesize_memo()

# Notify clients that the memo resource has changed
await self.request_context.session.send_resource_updated("memo://insights")
await self.request_context.session.send_resource_updated(AnyUrl("memo://insights"))

return [types.TextContent(type="text", text="Insight added to memo")]
if not arguments:
Expand Down
52 changes: 41 additions & 11 deletions src/sqlite/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8851072

Please sign in to comment.