From 845546c53f9668617bcecc2be7eb9790ec6c613d Mon Sep 17 00:00:00 2001 From: Maxi Fernandez <45922974+Maxi91f@users.noreply.github.com> Date: Thu, 31 Jul 2025 12:04:28 -0300 Subject: [PATCH] docs: update get_state and set_state references (#1306) --- docs/python-sdk/fastmcp-server-context.mdx | 4 ++-- docs/servers/context.mdx | 4 ++-- src/fastmcp/server/context.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/python-sdk/fastmcp-server-context.mdx b/docs/python-sdk/fastmcp-server-context.mdx index edca73dda..b61ba25d7 100644 --- a/docs/python-sdk/fastmcp-server-context.mdx +++ b/docs/python-sdk/fastmcp-server-context.mdx @@ -45,8 +45,8 @@ def my_tool(x: int, ctx: Context) -> str: client_id = ctx.client_id # Manage state across the request - ctx.set_state_value("key", "value") - value = ctx.get_state_value("key") + ctx.set_state("key", "value") + value = ctx.get_state("key") return str(x) ``` diff --git a/docs/servers/context.mdx b/docs/servers/context.mdx index 91d5c2a2a..5b766f458 100644 --- a/docs/servers/context.mdx +++ b/docs/servers/context.mdx @@ -222,8 +222,8 @@ async def secure_operation(data: str, ctx: Context) -> str: ``` **Method signatures:** -- **`ctx.set_state_value(key: str, value: Any) -> None`**: Store a value in the context state -- **`ctx.get_state_value(key: str) -> Any`**: Retrieve a value from the context state (returns None if not found) +- **`ctx.set_state(key: str, value: Any) -> None`**: Store a value in the context state +- **`ctx.get_state(key: str) -> Any`**: Retrieve a value from the context state (returns None if not found) **State Inheritance:** When a new context is created (nested contexts), it inherits a copy of its parent's state. This ensures that: diff --git a/src/fastmcp/server/context.py b/src/fastmcp/server/context.py index 5af3597b7..d06d4eb42 100644 --- a/src/fastmcp/server/context.py +++ b/src/fastmcp/server/context.py @@ -85,8 +85,8 @@ class Context: client_id = ctx.client_id # Manage state across the request - ctx.set_state_value("key", "value") - value = ctx.get_state_value("key") + ctx.set_state("key", "value") + value = ctx.get_state("key") return str(x) ```