-
Notifications
You must be signed in to change notification settings - Fork 88
feat: Add targeted operations agent server #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
adamoutler
wants to merge
14
commits into
makeplane:main
Choose a base branch
from
adamoutler:plane-agent
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5c77584
feat: Add targeted operations agent server
adamoutler a1e29a2
Address coderabbit issues
adamoutler 84dba24
Add E2E tests for pagination cursor and label exception handling
adamoutler 6505634
Address CodeRabbit second-pass issues
adamoutler e72b9e5
Address CodeRabbit third-pass issues
adamoutler 7afe99f
Harden workflow.py begin_work error handling
adamoutler b4603ac
Consolidate resolver imports and remove unused import in workflow.py
adamoutler 45f0bc9
feat: optimize MCP help response for terminal display and LLM context
adamoutler c1d12ac
fix(fastmcp): Monkey-patch _docket_lifespan to completely prevent fak…
adamoutler b06e5ab
Merge branch 'main' into plane-agent
adamoutler b1ab0e7
fix: eliminate gemini-CLI-specific formatting in favor of MCP standard.
adamoutler 2603333
style(agent): fix remaining ruff lint errors (line length and unused …
adamoutler f5129fe
feat: add stickies to help orientation and unpretty print JSON
adamoutler f454312
feat: convert to yaml to save 14.1% over json, >95.5% total measured …
adamoutler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| name: CI / CD | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| - master | ||
| - ai-journeys-rearchitecture | ||
| - plane-agent | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| - master | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Run Tests | ||
| runs-on: ubuntu-latest | ||
| container: | ||
| image: python:3.12 | ||
| steps: | ||
| - name: Setup and Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Run tests | ||
| run: | | ||
| set +e | ||
| pip install '.[dev]' pytest pytest-asyncio pytest-mock pytest-timeout respx requests-mock anyio | ||
| pytest -v > test-output.log 2>&1 | ||
| TEST_EXIT=$? | ||
| cat test-output.log | ||
| exit $TEST_EXIT | ||
|
|
||
| build-and-push: | ||
| name: Build & Push Docker | ||
| needs: test | ||
| runs-on: ubuntu-latest | ||
| if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' | ||
| permissions: | ||
| packages: write | ||
| contents: read | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up QEMU | ||
| uses: docker/setup-qemu-action@v3 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Log in to Docker Hub | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
| password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
|
||
| - name: Set image tags | ||
| id: tags | ||
| run: | | ||
| BRANCH_TAG=$(echo "${{ github.ref_name }}" | sed 's|/|-|g') | ||
| IMAGE="${{ secrets.DOCKERHUB_USERNAME }}/plane-mcp-server" | ||
| TAGS="${IMAGE}:${BRANCH_TAG}" | ||
| if [ "${{ github.ref_name }}" = "main" ] || [ "${{ github.ref_name }}" = "master" ]; then | ||
| TAGS="${TAGS},${IMAGE}:latest" | ||
| fi | ||
| echo "tags=${TAGS}" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Build and push | ||
| uses: docker/build-push-action@v5 | ||
| with: | ||
| context: . | ||
| push: true | ||
| platforms: linux/amd64,linux/arm64 | ||
| tags: ${{ steps.tags.outputs.tags }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,4 +55,4 @@ dmypy.json | |
| .env.test.local | ||
|
|
||
| # Ignore cursor AI rules | ||
| .cursor/rules/codacy.mdc | ||
| .cursor/rules/codacy.mdc | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # This docker-compose configuration is intended for stand-alone MCP server testing. | ||
| services: | ||
| plane-mcp: | ||
| build: . | ||
| container_name: plane-mcp | ||
| restart: unless-stopped | ||
| ports: | ||
| - "${FASTMCP_PORT:-8211}:${FASTMCP_PORT:-8211}" | ||
| environment: | ||
| - PLANE_API_KEY=${PLANE_API_KEY} | ||
| - PLANE_WORKSPACE_SLUG=${PLANE_WORKSPACE_SLUG} | ||
| - PLANE_BASE_URL=${PLANE_BASE_URL} | ||
| - FASTMCP_PORT=${FASTMCP_PORT:-8211} | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| - REDIS_HOST=redis | ||
| - REDIS_PORT=6379 | ||
| entrypoint: ["python", "-m", "plane_mcp"] | ||
| command: ["http"] | ||
|
adamoutler marked this conversation as resolved.
|
||
| depends_on: | ||
| - redis | ||
|
|
||
| redis: | ||
| image: redis:alpine | ||
| container_name: plane-redis | ||
| restart: unless-stopped | ||
| ports: | ||
| - "6379:6379" | ||
| volumes: | ||
| - redis_data:/data | ||
|
|
||
| volumes: | ||
| redis_data: | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,31 @@ | ||
| """Plane MCP Server - A Model Context Protocol server for Plane integration.""" | ||
|
|
||
| import os | ||
| from contextlib import asynccontextmanager | ||
| from fastmcp import FastMCP | ||
|
|
||
| _original_fastmcp_init = FastMCP.__init__ | ||
|
|
||
| def _patched_fastmcp_init(self, *args, **kwargs): | ||
| if "tasks" not in kwargs: | ||
| kwargs["tasks"] = os.getenv("PLANE_ALLOW_MEMORY_TASKS", "false").lower() == "true" | ||
| _original_fastmcp_init(self, *args, **kwargs) | ||
| self.__mcp_patched_tasks_enabled = kwargs.get("tasks", False) | ||
|
|
||
| FastMCP.__init__ = _patched_fastmcp_init | ||
|
|
||
| _original_docket_lifespan = FastMCP._docket_lifespan | ||
|
|
||
| @asynccontextmanager | ||
| async def _patched_docket_lifespan(self): | ||
| tasks_enabled = getattr(self, "__mcp_patched_tasks_enabled", True) | ||
| if not tasks_enabled: | ||
| try: | ||
| yield | ||
| finally: | ||
| pass | ||
| return | ||
| async with _original_docket_lifespan(self): | ||
| yield | ||
|
|
||
| FastMCP._docket_lifespan = _patched_docket_lifespan |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| """Main entry point for the Plane MCP Server.""" | ||
|
|
||
| import os | ||
| import sys | ||
| from contextlib import asynccontextmanager | ||
| from enum import Enum | ||
|
|
||
| import uvicorn | ||
| from fastmcp.utilities.logging import get_logger | ||
| from starlette.applications import Starlette | ||
| from starlette.middleware.cors import CORSMiddleware | ||
| from starlette.routing import Mount | ||
|
|
||
| from plane_mcp.journey.server import get_header_mcp, get_stdio_mcp | ||
|
|
||
| logger = get_logger(__name__) | ||
|
|
||
|
|
||
| class ServerMode(Enum): | ||
| STDIO = "stdio" | ||
| SSE = "sse" | ||
| HTTP = "http" | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
|
|
||
| @asynccontextmanager | ||
| async def combined_lifespan(oauth_app, header_app, sse_app): | ||
| """Combine lifespans from both OAuth and Header MCP apps.""" | ||
| # Start both lifespans | ||
| async with oauth_app.lifespan(oauth_app): | ||
| async with header_app.lifespan(header_app): | ||
| async with sse_app.lifespan(sse_app): | ||
| yield | ||
|
|
||
|
|
||
| def main() -> None: | ||
| """Run the MCP server.""" | ||
| server_mode = ServerMode.STDIO | ||
| if len(sys.argv) > 1: | ||
| try: | ||
| server_mode = ServerMode(sys.argv[1]) | ||
| except ValueError: | ||
| valid_modes = ", ".join(m.value for m in ServerMode) | ||
| raise ValueError(f"Invalid server mode '{sys.argv[1]}'. Valid modes: {valid_modes}") from None | ||
|
|
||
| if server_mode == ServerMode.STDIO: | ||
| # Validate API_KEY and PLANE_WORKSPACE_SLUG are set | ||
| if not os.getenv("PLANE_API_KEY"): | ||
| raise ValueError("PLANE_API_KEY is not set") | ||
| if not os.getenv("PLANE_WORKSPACE_SLUG"): | ||
| raise ValueError("PLANE_WORKSPACE_SLUG is not set") | ||
|
|
||
| get_stdio_mcp().run() | ||
| return | ||
|
|
||
| if server_mode == ServerMode.SSE: | ||
| raise NotImplementedError( | ||
| "SSE mode is not implemented in the agent server. " | ||
| "Use 'stdio' or 'http'. SSE transport is defined in the MCP spec " | ||
| "but not supported by this endpoint." | ||
| ) | ||
|
|
||
| if server_mode == ServerMode.HTTP: | ||
| http_mcp = get_header_mcp() | ||
| http_app = http_mcp.http_app(transport="streamable-http") | ||
|
|
||
| app = Starlette( | ||
| routes=[ | ||
| Mount("/", app=http_app), | ||
| ], | ||
| lifespan=lambda app: http_app.lifespan(http_app), | ||
| ) | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| app.add_middleware( | ||
| CORSMiddleware, | ||
| allow_origins=["*"], | ||
| allow_credentials=False, | ||
| allow_methods=["*"], | ||
| allow_headers=["*"], | ||
| ) | ||
|
|
||
| port = int(os.getenv("FASTMCP_PORT", "8211")) | ||
| logger.info(f"Starting HTTP server for Streamable HTTP at / on port {port}") | ||
| uvicorn.run(app, host="0.0.0.0", port=port, log_level="info") | ||
| return | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.