Skip to content

Commit 39a1e59

Browse files
authored
feat: Set instructions in code (#1838)
1 parent 2df8a0f commit 39a1e59

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

src/fastmcp/server/server.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,10 @@ def name(self) -> str:
329329
def instructions(self) -> str | None:
330330
return self._mcp_server.instructions
331331

332+
@instructions.setter
333+
def instructions(self, value: str | None) -> None:
334+
self._mcp_server.instructions = value
335+
332336
@property
333337
def version(self) -> str | None:
334338
return self._mcp_server.version

tests/server/test_server.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ async def test_create_server(self):
3535
assert mcp.name.startswith("FastMCP-")
3636
assert mcp.instructions == "Server instructions"
3737

38+
async def test_change_instruction(self):
39+
mcp = FastMCP(instructions="Server instructions")
40+
assert mcp.instructions == "Server instructions"
41+
mcp.instructions = "New instructions"
42+
assert mcp.instructions == "New instructions"
43+
3844
async def test_non_ascii_description(self):
3945
"""Test that FastMCP handles non-ASCII characters in descriptions correctly"""
4046
mcp = FastMCP()

0 commit comments

Comments
 (0)