Skip to content

McpAsyncServer.removeResourceTemplate does not send notifications/resources/list_changed #1265

Closed

Description

@subhashpolisetti

Bug description
McpAsyncServer.removeResourceTemplate(String) removes the template but never sends notifications/resources/list_changed, even when the server declares resources.listChanged. Its Javadoc says the returned Mono "completes when clients have been notified of the change", and the other runtime methods (addResourceTemplate, addResource, removeResource, addTool, removeTool, addPrompt, removePrompt) all send their list_changed notification when listChanged is true. Clients that rely on the notification keep showing the removed template until they re-list.

McpSyncServer.removeResourceTemplate delegates to the async server, so it has the same problem.

The method has looked like this since it was added in #576 (v0.14.0). It is the same on main, 2.1.x and 1.1.x.

Spec: Resources, List Changed Notification: "When the list of available resources changes, servers that declared the listChanged capability SHOULD send a notification."

Environment
main @ f19d122 (2.2.0-SNAPSHOT), also 2.1.0. Java 21.0.5, macOS 26.6.2.

Steps to reproduce

  1. Build an McpAsyncServer with .capabilities(ServerCapabilities.builder().resources(false, true).build()) and register a resource template.
  2. Call removeResourceTemplate(<uriTemplate>).
  3. No notifications/resources/list_changed is sent.

Expected behavior
When a template is removed and resources.listChanged is true, the server sends notifications/resources/list_changed, in the same way removeResource does. Removing a template that is not registered sends nothing, which also matches removeResource.

Minimal Complete Reproducible example
Failing test in the mcp-test module (ResourceTemplateManagementTests):

@Test
void testRemoveResourceTemplateNotifiesListChanged() {
	ResourceTemplate template = ResourceTemplate.builder(TEST_TEMPLATE_URI, TEST_TEMPLATE_NAME).build();

	McpServerFeatures.AsyncResourceTemplateSpecification specification = new McpServerFeatures.AsyncResourceTemplateSpecification(
			template, (exchange, req) -> Mono.just(ReadResourceResult.builder(List.of()).build()));

	mcpAsyncServer = McpServer.async(mockTransportProvider)
		.serverInfo("test-server", "1.0.0")
		.capabilities(ServerCapabilities.builder().resources(false, true).build())
		.resourceTemplates(specification)
		.build();

	StepVerifier.create(mcpAsyncServer.removeResourceTemplate(TEST_TEMPLATE_URI)).verifyComplete();

	// Fails on main: no message was sent
	assertThat(mockTransportProvider.getTransport().getAllSentMessages()).singleElement()
		.isInstanceOfSatisfying(JSONRPCNotification.class, notification -> assertThat(notification.method())
			.isEqualTo(McpSchema.METHOD_NOTIFICATION_RESOURCES_LIST_CHANGED));
}

Activity

  1. added
    bugSomething isn't working
    P3Nice to haves, rare edge cases
    on Oct 23, 2026
  2. added theissue type on Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Nice to haves, rare edge casesarea/serverbugSomething isn't working

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions