Apache Sling can expose a Model Context Protocol (MCP) server from a running Sling instance. This allows MCP-aware clients to inspect and interact with Sling through HTTP, using tools and prompts contributed by Sling bundles.
The MCP endpoint is exposed at /bin/mcp.
The Sling MCP server is intended for development and diagnostics against a running Sling instance.
This page documents a setup based on the apache/sling Docker image. Pending a release of version 15, a snapshot version is ued.
Docker is required for the setup described here.
Until Sling Starter 15 is released, use the apache/sling:snapshot Docker image.
Launch the Sling Starter container image and add both MCP feature models using --extra-features.
docker run --rm -p 8080:8080 \
apache/sling:snapshot oak_tar \
--extra-features \
mvn:org.apache.sling/org.apache.sling.mcp-server/0.1.4/slingosgifeature/main \
mvn:org.apache.sling/org.apache.sling.mcp-server-contributions/0.1.0/slingosgifeature/main
Configuration depends on the particular MCP client you are using. The key points are:
http://localhost:8080/bin/mcpThe MCP servlet allows access only for admin users. This prevents unauthorized access to potentially sensitive information and operations exposed through the MCP server.
Read on for instructions for specific clients.
OpenCode can connect to the Sling MCP server using a remote MCP definition.
Example opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"sling": {
"type": "remote",
"url": "http://localhost:8080/bin/mcp",
"headers": {
"Authorization": "Basic YWRtaW46YWRtaW4="
}
}
}
}
Claude Code can connect to the Sling MCP server as a remote HTTP MCP server.
Example command:
claude mcp add --transport http \
sling http://localhost:8080/bin/mcp \
--header "Authorization: Basic YWRtaW46YWRtaW4="
The base org.apache.sling.mcp-server bundle provides the HTTP MCP endpoint and prompt discovery from the Sling repository.
The org.apache.sling.mcp-server-contributions bundle adds the default Sling-specific tools and prompts.
The following tools are available by default:
logs Returns recent Sling logs with optional filtering by regex, log level and maximum number of entries.recent-requests Returns recent Sling requests, including method, path, user id and request progress log output.diagnose-osgi-bundle Diagnoses inactive or problematic OSGi bundles and Declarative Services components.The following prompts are available by default:
troubleshoot A troubleshooting guide for common Sling and MCP server issues.new-sling-servlet A prompt template for creating a new Sling servlet based on a resource type.Prompts are discovered from repository content under /libs/sling/mcp/prompts.
Once Sling is running and your MCP client is configured:
http://localhost:8080/bin/mcplogs, recent-requests, diagnose-osgi-bundletroubleshoot, new-sling-servletIf the MCP endpoint is not reachable, verify that both MCP features were added successfully and that the client sends valid Basic authentication credentials.
Once the server is connected, prompts like the following are good starting points:
Analyse errors from my Sling instanceWhere was most of the time spent in the request to /starter.html?Why did bundle org.acme.foo fail to start?The Sling MCP server is extensible in two main ways:
McpServerContribution services to expose new tools, prompts, resources or completions/libs/sling/mcp/prompts so that it is discovered automaticallyThis makes it possible to keep the server itself minimal while packaging Sling-specific or project-specific MCP capabilities in separate bundles.