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 .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
groups:
github-actions:
patterns:
- "*"
62 changes: 62 additions & 0 deletions .github/workflows/fix-license-header.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Fix License Headers

on:
pull_request_target:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
header-license-fix:
runs-on: ubuntu-latest

permissions:
contents: write
pull-requests: write

steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout the branch from the PR that triggered the job
run: gh pr checkout ${{ github.event.pull_request.number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Fix License Header
# pin to include https://github.com/apache/skywalking-eyes/pull/168
uses: apache/skywalking-eyes/header@07a607ff5b0759f5ed47306c865aac50fe9b3985
with:
mode: fix

- name: List files changed
id: files-changed
shell: bash -l {0}
run: |
set -ex
export CHANGES=$(git status --porcelain | tee /tmp/modified.log | wc -l)
cat /tmp/modified.log

echo "N_CHANGES=${CHANGES}" >> $GITHUB_OUTPUT

git diff

- name: Commit any changes
if: steps.files-changed.outputs.N_CHANGES != '0'
shell: bash -l {0}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

git pull --no-tags

git add *
git commit -m "Automatic application of license header"

git config push.default upstream
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52 changes: 52 additions & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
header:
license:
spdx-id: Datalayer
copyright-owner: Datalayer, Inc.
copyright-year: 2023-2025
content: |
Copyright (c) [year] [owner]
Distributed under the terms of the Modified BSD License.

paths-ignore:
- '**/*.toml'
- '**/*.apt'
- '**/*.cedar'
- '**/*.dash'
- '**/*.fga'
- '**/*.ipynb'
- '**/*.j2'
- '**/*.json'
- '**/*.mamba'
- '**/*.md'
- '**/*.mdx'
- '**/*.mod'
- '**/*.nblink'
- '**/*.rego'
- '**/*.sum'
- '**/*.svg'
- '**/*.template'
- '**/*.tsbuildinfo'
- '**/*.txt'
- '**/*.yaml'
- '**/*.yml'
- '**/*_key'
- '**/*_key.pub'
- '**/.*'
- '**/LICENSE.txt'
- '**/MANIFEST.in'
- '**/build'
- '**/lib'
- '**/node_modules'
- '**/schemas'
- '**/ssh/*'
- '**/static'
- '**/themes'
- '**/typings'
- '**/*.patch'
- '**/*.bundle.js'
- '**/*.map.js'
- 'LICENSE'
- 'src/stories'
- '.husky/pre-commit'

comment: on-failure
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
[![License](https://img.shields.io/badge/license-BSD--3--Clause-green)](LICENSE)
[![Docker](https://img.shields.io/badge/docker-ready-blue)](Dockerfile)

> **A powerful, production-ready framework for composing and orchestrating Model Context Protocol (MCP) servers with advanced management capabilities, REST API, and modern Web UI.**
> **Similar to Docker Compose - Orchestrate Model Context Protocol (MCP) servers with management capabilities, REST API, and Web UI.**

## 🎯 Overview

Expand Down
13 changes: 13 additions & 0 deletions examples/mcp-auth/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,19 @@ agent:
@echo ""
mcp-auth-agent azure-openai:gpt-4o-mini


# Run MCP Inspector
inspector:
@echo "πŸ” Starting Model Context Protocol Inspector..."
npx @modelcontextprotocol/inspector

# Test Dynamic Client Registration
test-dcr:
@echo "πŸ§ͺ Testing Dynamic Client Registration (DCR)..."
@echo "Make sure the server is running in another terminal: make server"
@echo ""
python test_dcr.py

# Run tests
test:
@echo "πŸ§ͺ Running tests..."
Expand Down
13 changes: 8 additions & 5 deletions examples/mcp-auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ A clear, educational example demonstrating OAuth2 authentication for MCP (Model
## πŸ“š What You'll Learn

- **OAuth2** - Authorization Code flow with PKCE
- **Dynamic Client Registration (DCR)** - RFC 7591 implementation for automatic client registration
- **MCP Authorization** - Official specification (2025-06-18)
- **Security** - Token validation, CSRF protection, resource indicators
- **MCP SDK** - Building servers with FastMCP and clients with MCP SDK
Expand All @@ -39,9 +40,11 @@ make install
|------|---------|------------------|
| **[docs/QUICKSTART.md](docs/QUICKSTART.md)** | Get running in 5 minutes | You want to try it immediately |
| **[docs/GITHUB.md](docs/GITHUB.md)** | GitHub OAuth app setup | Setting up for the first time |
| **[docs/INSPECTOR.md](docs/INSPECTOR.md)** | MCP Inspector setup and testing | You want to test with MCP Inspector |
| **[docs/FLOW_EXPLAINED.md](docs/FLOW_EXPLAINED.md)** | Detailed OAuth flow | You want to understand how it works |
| **[docs/DIAGRAMS.md](docs/DIAGRAMS.md)** | Visual explanations | You prefer diagrams |
| **[docs/IMPLEMENTATION.md](docs/IMPLEMENTATION.md)** | Technical details | You're implementing your own |
| **[docs/DYNAMIC_CLIENT_REGISTRATION.md](docs/DYNAMIC_CLIENT_REGISTRATION.md)** | Dynamic Client Registration (DCR) | You want to understand automatic client registration |

## πŸ“ Project Structure

Expand Down Expand Up @@ -75,7 +78,7 @@ mcp-auth/
- OAuth2 endpoints integrated with FastAPI
- Three example tools (calculator, greeter, server_info)
- Token validation middleware
- Compatible with both SSE and STDIO transports
- Uses **HTTP Streaming (NDJSON)** transport for efficient communication

### 2. **MCP Client** (`mcp_auth_example/client.py`)
- Built with **official MCP Python SDK**
Expand All @@ -101,22 +104,22 @@ mcp-auth/
- Implements MCP Authorization specification (2025-06-18)
- Exposes OAuth metadata endpoints (RFC 9728, RFC 8414)
- Validates access tokens before serving tools
- Provides MCP tools via HTTP/SSE transport
- Provides MCP tools via **HTTP Streaming (NDJSON)** transport
- Tools: calculator (add, multiply), greeter (hello, goodbye), server info

### 2. **MCP Client** (`mcp_auth_example/client.py`)
- Handles OAuth2 flow with GitHub
- Automatically opens browser for user authentication
- Manages access tokens
- Connects to MCP server using **MCP SDK client**
- Makes authenticated requests via MCP protocol (SSE transport)
- Demonstrates proper MCP tool invocation
- Makes authenticated requests via MCP protocol (**HTTP Streaming transport**)
- Demonstrates proper MCP tool invocation with NDJSON format

### 3. **Pydantic AI Agent** (`mcp_auth_example/agent.py`) ✨ NEW
- Interactive CLI agent powered by **pydantic-ai**
- Uses **Anthropic Claude Sonnet 4.5** model
- Automatically authenticates with OAuth2
- Connects to MCP server with authenticated tools
- Connects to MCP server with authenticated tools via HTTP Streaming
- Natural language interface to MCP tools
- Example: "What is 15 + 27?" β†’ Uses calculator_add tool

Expand Down
22 changes: 11 additions & 11 deletions examples/mcp-auth/docs/AGENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ The agent provides a natural language interface to the MCP server tools, powered
β”‚ β”‚ β”‚
β”‚ β–Ό β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ MCPServerSSE (pydantic_ai.mcp) β”‚ β”‚
β”‚ β”‚ - URL: http://localhost:8080/sse β”‚ β”‚
β”‚ β”‚ MCPServerStreamableHTTP (pydantic_ai.mcp) β”‚ β”‚
β”‚ β”‚ - URL: http://localhost:8080/mcp β”‚ β”‚
β”‚ β”‚ - Auth: Bearer token from OAuth β”‚ β”‚
β”‚ β”‚ - Tools: calculator_*, greeter_*, get_server_info β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
Expand All @@ -77,7 +77,7 @@ The agent provides a natural language interface to the MCP server tools, powered
β”‚ MCP Server (server.py) β”‚
β”‚ - Validates Bearer token with GitHub β”‚
β”‚ - Executes tool functions β”‚
β”‚ - Returns results via SSE β”‚
β”‚ - Returns results via HTTP Streaming (NDJSON) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

Expand All @@ -88,16 +88,16 @@ The agent provides a natural language interface to the MCP server tools, powered
- Manages PKCE flow for security
- Returns access token for MCP server

2. **Agent Setup** (`agent.py`)
3. **Agent Setup** (`agent.py`)
- Creates `httpx.AsyncClient` with Bearer token
- Initializes `MCPServerSSE` connection
- Initializes `MCPServerStreamableHTTP` connection
- Creates `Agent` with Anthropic Claude model
- Registers MCP server as toolset

3. **Tool Invocation Flow**
4. **Tool Invocation Flow**
- User types natural language query
- Agent (Claude) analyzes query and decides which tool to call
- Agent calls tool via MCP protocol (HTTP SSE)
- Agent calls tool via MCP protocol (HTTP Streaming)
- MCP server validates token and executes tool
- Agent receives result and formulates response
- Agent displays natural language answer to user
Expand All @@ -121,17 +121,17 @@ if oauth.authenticate():
```python
import httpx
from pydantic_ai import Agent
from pydantic_ai.mcp import MCPServerSSE
from pydantic_ai.mcp import MCPServerStreamableHTTP

# Create HTTP client with authentication
http_client = httpx.AsyncClient(
headers={"Authorization": f"Bearer {token}"},
timeout=httpx.Timeout(30.0)
timeout=30.0
)

# Connect to MCP server
mcp_server = MCPServerSSE(
url=f"{server_url}/sse",
mcp_server = MCPServerStreamableHTTP(
url=f"{server_url}/mcp",
http_client=http_client
)

Expand Down
Loading