Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions model-context-protocol/mcp-apps-server/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/gradlew text eol=lf
*.bat text eol=crlf
*.jar binary
37 changes: 37 additions & 0 deletions model-context-protocol/mcp-apps-server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
HELP.md
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/
68 changes: 68 additions & 0 deletions model-context-protocol/mcp-apps-server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
Spring AI MCP Apps Server
===
This example highlight how to use metadata on an MCP server's tools and
resources to enable [MCP Apps](https://modelcontextprotocol.io/extensions/apps/overview).

Building and Running the Server
---
This example is built with Gradle. There is a Gradle wrapper available in the
project directory, so you can build an executable JAR file like this:

```
./gradlew build
```

Then you can run it like this:

```
java -jar build/libs/mcp-apps-server-0.0.1-SNAPSHOT.jar
```

Optionally, you can use the Spring Boot Gradle plugin to build and run the
app like this:

```
./gradlew bootRun
```

Or, if you want, run the application through your IDE using the facilities
of your favorite IDE.

Once the application starts, the MCP server will be listening on port
3001.

Using the MCP App Server
---
To see the MCP App in action, you'll need to configure the server in an
MCP client that supports MCP Apps. This includes MCP Jam and Claude
Desktop. Goose also supports MCP Apps, but does not (yet, as of version
1.27.2) support the ability for the app to update the context model, so
at least for now you cannot use Goose.

When you configure the MCP server, choose Streamable HTTP as the transport
protocol and set the URL to "http://localhost:3001/mcp".

Claude Desktop (at least as of version 1.1.5749) does not support Streamable
HTTP. But you can still use a Streamable HTTP MCP server by using the
mcp-remote (STDIO transport) MCP server to proxy to the Streamable HTTP
server. Configure it in the Claude Desktop configuration JSON like this:

```
"mcpServers": {
"dice-tools": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"http://localhost:3001/mcp"
]
}
}
```

After configuring the MCP server in your MCP client, type "Roll the dice"
in the chat. If everything is configured correctly, after a moment you
should see a pair of dice, rolled to some values. Then ask "What was the
result?" to verify that the application was about to update the model
context. Then click the "Roll Dice" button to re-roll the dice and ask
again.
42 changes: 42 additions & 0 deletions model-context-protocol/mcp-apps-server/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
plugins {
id 'java'
id 'org.springframework.boot' version '4.0.3'
id 'io.spring.dependency-management' version '1.1.7'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
description = 'mcp-apps-server'

java {
toolchain {
languageVersion = JavaLanguageVersion.of(25)
}
}

repositories {
mavenCentral()
maven { url = 'https://repo.spring.io/snapshot' }
maven {url = 'https://central.sonatype.com/repository/maven-snapshots/'}
}

ext {
set('springAiVersion', "2.0.0-SNAPSHOT")
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-webmvc'
implementation 'org.springframework.ai:spring-ai-starter-mcp-server-webmvc'
testImplementation 'org.springframework.boot:spring-boot-starter-webmvc-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

dependencyManagement {
imports {
mavenBom "org.springframework.ai:spring-ai-bom:${springAiVersion}"
}
}

tasks.named('test') {
useJUnitPlatform()
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading