Remove all notes resource

This commit is contained in:
Chris Coutinho
2025-05-05 03:48:14 +02:00
parent ca980ec141
commit 43971ad0b2
2 changed files with 21 additions and 23 deletions
-13
View File
@@ -56,19 +56,6 @@ def notes_get_settings():
return client.notes_get_settings()
@mcp.resource("notes://all")
def nc_notes_get_all():
"""Get all user notes"""
ctx = (
mcp.get_context()
) # https://github.com/modelcontextprotocol/python-sdk/issues/244
client: NextcloudClient = ctx.request_context.lifespan_context.client
return client.notes_get_all()
# Removed nc_notes_get_note resource
@mcp.tool()
def nc_get_note(note_id: int, ctx: Context):
"""Get user note using note id"""
+15 -4
View File
@@ -8,6 +8,7 @@ from nextcloud_mcp_server.client import NextcloudClient
# Tests assume NEXTCLOUD_HOST, NEXTCLOUD_USERNAME, NEXTCLOUD_PASSWORD env vars are set
@pytest.fixture(scope="module")
def nc_client() -> NextcloudClient:
"""
@@ -21,6 +22,7 @@ def nc_client() -> NextcloudClient:
assert os.getenv("NEXTCLOUD_PASSWORD"), "NEXTCLOUD_PASSWORD env var not set"
return NextcloudClient.from_env()
@pytest.mark.integration
def test_note_crud_integration(nc_client: NextcloudClient):
"""
@@ -33,7 +35,9 @@ def test_note_crud_integration(nc_client: NextcloudClient):
create_content = f"Content for integration test {unique_id}"
create_category = "IntegrationTesting"
created_note = None # Initialize to ensure cleanup happens even if create fails mid-assert
created_note = (
None # Initialize to ensure cleanup happens even if create fails mid-assert
)
try:
print(f"\nAttempting to create note: {create_title}")
created_note = nc_client.notes_create_note(
@@ -125,7 +129,9 @@ def test_note_crud_integration(nc_client: NextcloudClient):
with pytest.raises(HTTPStatusError) as excinfo_del:
nc_client.notes_get_note(note_id=note_id_to_delete)
assert excinfo_del.value.response.status_code == 404
print(f"Reading deleted note ID: {note_id_to_delete} correctly failed with 404.")
print(
f"Reading deleted note ID: {note_id_to_delete} correctly failed with 404."
)
except HTTPStatusError as e:
# If deletion fails unexpectedly, log it but don't fail the test here
@@ -134,7 +140,10 @@ def test_note_crud_integration(nc_client: NextcloudClient):
except Exception as e:
print(f"Unexpected error during cleanup: {e}")
else:
print("Skipping delete step as note creation might have failed or ID was not available.")
print(
"Skipping delete step as note creation might have failed or ID was not available."
)
@pytest.mark.integration
def test_delete_nonexistent_note(nc_client: NextcloudClient):
@@ -144,4 +153,6 @@ def test_delete_nonexistent_note(nc_client: NextcloudClient):
with pytest.raises(HTTPStatusError) as excinfo:
nc_client.notes_delete_note(note_id=non_existent_id)
assert excinfo.value.response.status_code == 404
print(f"Deleting non-existent note ID: {non_existent_id} correctly failed with 404.")
print(
f"Deleting non-existent note ID: {non_existent_id} correctly failed with 404."
)