From f79b957644eee7a6699718e1af65563e3189a5a9 Mon Sep 17 00:00:00 2001 From: Chris Coutinho Date: Sun, 31 Aug 2025 21:08:04 +0200 Subject: [PATCH] test: Update tests with McpError --- nextcloud_mcp_server/models/notes.py | 2 +- nextcloud_mcp_server/server/notes.py | 4 +++- tests/integration/test_mcp.py | 10 ++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/nextcloud_mcp_server/models/notes.py b/nextcloud_mcp_server/models/notes.py index 6173565..9bdc627 100644 --- a/nextcloud_mcp_server/models/notes.py +++ b/nextcloud_mcp_server/models/notes.py @@ -19,7 +19,7 @@ class Note(BaseModel): favorite: bool = Field( default=False, description="Whether note is marked as favorite" ) - etag: Optional[str] = Field(None, description="ETag for versioning") + etag: str = Field(description="ETag for versioning") readonly: bool = Field(default=False, description="Whether note is read-only") @property diff --git a/nextcloud_mcp_server/server/notes.py b/nextcloud_mcp_server/server/notes.py index 537429c..cd21d45 100644 --- a/nextcloud_mcp_server/server/notes.py +++ b/nextcloud_mcp_server/server/notes.py @@ -179,7 +179,9 @@ def configure_notes_tools(mcp: FastMCP): async def nc_notes_append_content( note_id: int, content: str, ctx: Context ) -> AppendContentResponse: - """Append content to an existing note with a clear separator. The tool automatically adds separators between existing and new content - do not include separators in your content.""" + """Append content to an existing note. The tool adds a `\n---\n` + between the note and what will be appended.""" + logger.info("Appending content to note %s", note_id) client: NextcloudClient = ctx.request_context.lifespan_context.client try: diff --git a/tests/integration/test_mcp.py b/tests/integration/test_mcp.py index 136afeb..d4b30cc 100644 --- a/tests/integration/test_mcp.py +++ b/tests/integration/test_mcp.py @@ -334,13 +334,11 @@ async def test_mcp_notes_etag_conflict( ) # 4. Verify the update was rejected with a 412 error - # The MCP framework doesn't set isError=True for ErrorResponse, so check the response content + # With McpError, tools now return proper error responses + assert conflict_result.isError is True, "Update with stale ETag should fail" response_content = conflict_result.content[0].text - response_data = json.loads(response_content) - - assert response_data["success"] is False, "Update with stale ETag should fail" - assert "modified by someone else" in response_data["error"], ( - f"Expected conflict error message, got: {response_data}" + assert "modified by someone else" in response_content, ( + f"Expected conflict error message, got: {response_content}" ) logger.info("Successfully verified ETag conflict handling via MCP")