Skip to content
Open
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "Demonstration of Python FastMCP servers"
readme = "README.md"
requires-python = "==3.13.*"
dependencies = [
"fastmcp>=2.14.2",
"fastmcp==3.0.0b1",
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using an exact pin for a beta version (3.0.0b1) may cause issues with dependency resolution and updates. Consider using a minimum version constraint instead (e.g., "fastmcp>=3.0.0b1") to allow for future beta releases and the stable 3.0.0 release, or wait for the stable release before upgrading.

Suggested change
"fastmcp==3.0.0b1",
"fastmcp>=3.0.0b1",

Copilot uses AI. Check for mistakes.
"debugpy>=1.8.0",
"langchain-core>=0.3.0",
"mcp>=1.3.0",
Expand Down
8 changes: 4 additions & 4 deletions servers/auth_entra_mcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ def _get_user_id(self):
async def on_call_tool(self, context: MiddlewareContext, call_next):
user_id = self._get_user_id()
if context.fastmcp_context is not None:
context.fastmcp_context.set_state("user_id", user_id)
await context.fastmcp_context.set_state("user_id", user_id)
return await call_next(context)

async def on_read_resource(self, context: MiddlewareContext, call_next):
user_id = self._get_user_id()
if context.fastmcp_context is not None:
context.fastmcp_context.set_state("user_id", user_id)
await context.fastmcp_context.set_state("user_id", user_id)
return await call_next(context)


Expand Down Expand Up @@ -191,7 +191,7 @@ async def add_user_expense(

try:
# Read user_id stored by middleware
user_id = ctx.get_state("user_id")
user_id = await ctx.get_state("user_id")
if not user_id:
return "Error: Authentication required (no user_id present)"
expense_id = str(uuid.uuid4())
Expand All @@ -217,7 +217,7 @@ async def get_user_expenses(ctx: Context):
"""Get the authenticated user's expense data from Cosmos DB."""

try:
user_id = ctx.get_state("user_id")
user_id = await ctx.get_state("user_id")
if not user_id:
return "Error: Authentication required (no user_id present)"
query = "SELECT * FROM c WHERE c.user_id = @uid ORDER BY c.date DESC"
Expand Down
14 changes: 9 additions & 5 deletions servers/auth_keycloak_mcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import logging
import os
import uuid
import warnings
from datetime import date
from enum import Enum
from typing import Annotated
Expand Down Expand Up @@ -35,7 +36,7 @@

logging.basicConfig(
level=logging.WARNING,
format="%(message)s",
format="%(name)s: %(message)s",
handlers=[
RichHandler(
console=Console(stderr=True),
Expand All @@ -45,6 +46,9 @@
)
],
)
# Suppress OTEL 1.39 deprecation warnings and noisy logs
warnings.filterwarnings("ignore", category=DeprecationWarning, message=r".*Deprecated since version 1\.39\.0.*")
logging.getLogger("azure.monitor.opentelemetry.exporter._performance_counters._manager").setLevel(logging.ERROR)
logger = logging.getLogger("ExpensesMCP")
logger.setLevel(logging.INFO)

Expand Down Expand Up @@ -108,13 +112,13 @@ def _get_user_id(self):
async def on_call_tool(self, context: MiddlewareContext, call_next):
user_id = self._get_user_id()
if context.fastmcp_context is not None:
context.fastmcp_context.set_state("user_id", user_id)
await context.fastmcp_context.set_state("user_id", user_id)
return await call_next(context)

async def on_read_resource(self, context: MiddlewareContext, call_next):
user_id = self._get_user_id()
if context.fastmcp_context is not None:
context.fastmcp_context.set_state("user_id", user_id)
await context.fastmcp_context.set_state("user_id", user_id)
return await call_next(context)


Expand Down Expand Up @@ -155,7 +159,7 @@ async def add_user_expense(

try:
# Read user_id stored by middleware
user_id = ctx.get_state("user_id")
user_id = await ctx.get_state("user_id")
if not user_id:
return "Error: Authentication required (no user_id present)"
expense_id = str(uuid.uuid4())
Expand All @@ -181,7 +185,7 @@ async def get_user_expenses(ctx: Context):
"""Get the authenticated user's expense data from Cosmos DB."""

try:
user_id = ctx.get_state("user_id")
user_id = await ctx.get_state("user_id")
if not user_id:
return "Error: Authentication required (no user_id present)"
query = "SELECT * FROM c WHERE c.user_id = @uid ORDER BY c.date DESC"
Expand Down
Loading