Skip to content

Commit a38aad8

Browse files
committed
refactor: Restructure MCP server auto-configuration modules for better modularity
This commit reorganizes the Spring AI MCP (Model Context Protocol) server auto-configuration modules to improve separation of concerns and modularity: **Module Restructuring:** - Rename spring-ai-autoconfigure-mcp-server → spring-ai-autoconfigure-mcp-server-common , spring-ai-autoconfigure-mcp-server-sse - Rename spring-ai-autoconfigure-mcp-streamable-server-* → spring-ai-autoconfigure-mcp-server-streamable-* - Rename spring-ai-autoconfigure-mcp-stateless-server-* → spring-ai-autoconfigure-mcp-server-stateless-* **New Common Modules:** - Extract spring-ai-autoconfigure-mcp-server-properties for shared configuration properties - Create spring-ai-autoconfigure-mcp-server-common for shared auto-configuration logic between STDIO, SSE and Streamable-HTTP servers **Key Changes:** - Move McpServerProperties and related properties classes to dedicated properties module shared with all server modules. - Extract McpServerChangeNotificationProperties and McpServerStreamableHttpProperties - Refactor auto-configuration classes to use common base configurations - Update package names from *.autoconfigure to *.common.autoconfigure.properties - Consolidate tool callback converter logic into common module **Configuration Updates:** - Separate SSE-specific properties from general server properties - Improve conditional configuration with new condition classes - Update dependency references across all affected modules and starters - Maintain backward compatibility for existing property configurations **Impact:** - Better separation between different MCP server transport mechanisms (SSE, Streamable HTTP, Stateless) - Reduced code duplication across auto-configuration modules - Cleaner dependency management and module boundaries - Improved maintainability and extensibility for future MCP server features All existing functionality is preserved while providing a more modular and maintainable architecture for MCP server auto-configuration.
1 parent b4348e6 commit a38aad8

File tree

69 files changed

+917
-2452
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+917
-2452
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 5 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ jobs:
2929
name: Build branch
3030
runs-on: ubuntu-latest
3131
if: ${{ github.repository_owner == 'spring-projects' }}
32-
permissions:
33-
contents: read
34-
actions: read
3532
concurrency:
3633
group: continuous-integration-${{ github.ref }}
3734
cancel-in-progress: true # Skip if another build is running - next cron will trigger soon
@@ -46,63 +43,20 @@ jobs:
4643
- name: Checkout source code
4744
uses: actions/checkout@v4
4845

49-
- name: Check for new commits since last build
50-
id: changes
51-
run: |
52-
# Get the timestamp of the latest commit on this branch
53-
LATEST_COMMIT_TIME=$(git log -1 --format="%ct" HEAD)
54-
echo "Latest commit timestamp: $LATEST_COMMIT_TIME ($(date -d @$LATEST_COMMIT_TIME))"
55-
56-
# Get the last successful build time using GitHub API
57-
# Look for the most recent successful CI build on this branch
58-
LAST_SUCCESS=$(curl -s \
59-
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
60-
-H "Accept: application/vnd.github.v3+json" \
61-
"https://api.github.com/repos/${{ github.repository }}/actions/runs?branch=${{ github.ref_name }}&status=success&per_page=50" \
62-
| jq -r '.workflow_runs[] | select(.name == "CI/CD build" and .conclusion == "success") | .created_at' \
63-
| head -1)
64-
65-
if [ -n "$LAST_SUCCESS" ] && [ "$LAST_SUCCESS" != "null" ]; then
66-
LAST_SUCCESS_TIME=$(date -d "$LAST_SUCCESS" +%s)
67-
echo "Last successful build: $LAST_SUCCESS_TIME ($(date -d @$LAST_SUCCESS_TIME))"
68-
69-
if [ "$LATEST_COMMIT_TIME" -le "$LAST_SUCCESS_TIME" ]; then
70-
echo "No new commits since last successful build - skipping"
71-
echo "skip_build=true" >> $GITHUB_OUTPUT
72-
exit 0
73-
else
74-
echo "New commits found since last successful build - proceeding"
75-
echo "skip_build=false" >> $GITHUB_OUTPUT
76-
fi
77-
else
78-
echo "No previous successful build found - proceeding with build"
79-
echo "skip_build=false" >> $GITHUB_OUTPUT
80-
fi
81-
82-
- name: Build skipped - no new commits
83-
if: steps.changes.outputs.skip_build == 'true'
84-
run: |
85-
echo "✅ CI/CD build skipped - no new commits since last successful build"
86-
echo "This saves resources and reduces unnecessary builds"
87-
echo "The next scheduled build will check again for new commits"
88-
8946
- name: Free Disk Space
90-
if: steps.changes.outputs.skip_build != 'true'
9147
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
9248
with:
9349
large-packages: false
9450
docker-images: false
9551

9652
- name: Set up JDK 17
97-
if: steps.changes.outputs.skip_build != 'true'
9853
uses: actions/setup-java@v4
9954
with:
10055
java-version: '17'
10156
distribution: 'temurin'
10257
cache: 'maven'
10358

10459
- name: Configure Testcontainers
105-
if: steps.changes.outputs.skip_build != 'true'
10660
run: |
10761
echo "testcontainers.reuse.enable=true" > $HOME/.testcontainers.properties
10862
@@ -112,7 +66,6 @@ jobs:
11266
# key: docker-${{ runner.os }}-${{ hashFiles('**/OllamaImage.java') }}
11367

11468
- name: Build and test with Maven
115-
if: steps.changes.outputs.skip_build != 'true'
11669
env:
11770
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
11871
SPRING_AI_OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
@@ -132,20 +85,20 @@ jobs:
13285
fi
13386
13487
- name: Generate Java docs
135-
if: github.ref == 'refs/heads/main' && steps.changes.outputs.skip_build != 'true'
88+
if: github.ref == 'refs/heads/main'
13689
run: ./mvnw --batch-mode javadoc:aggregate
13790

13891
- name: Generate assembly
139-
if: github.ref == 'refs/heads/main' && steps.changes.outputs.skip_build != 'true'
92+
if: github.ref == 'refs/heads/main'
14093
working-directory: spring-ai-docs
14194
run: ../mvnw --batch-mode assembly:single
14295

14396
- name: Capture project version
144-
if: github.ref == 'refs/heads/main' && steps.changes.outputs.skip_build != 'true'
97+
if: github.ref == 'refs/heads/main'
14598
run: echo PROJECT_VERSION=$(mvn help:evaluate -Dexpression=project.version --quiet -DforceStdout) >> $GITHUB_ENV
14699

147100
- name: Setup SSH key
148-
if: github.ref == 'refs/heads/main' && steps.changes.outputs.skip_build != 'true'
101+
if: github.ref == 'refs/heads/main'
149102
env:
150103
DOCS_SSH_KEY: ${{ secrets.DOCS_SSH_KEY }}
151104
DOCS_SSH_HOST_KEY: ${{ secrets.DOCS_SSH_HOST_KEY }}
@@ -156,7 +109,7 @@ jobs:
156109
echo "$DOCS_SSH_HOST_KEY" > "$HOME/.ssh/known_hosts"
157110
158111
- name: Deploy docs
159-
if: github.ref == 'refs/heads/main' && steps.changes.outputs.skip_build != 'true'
112+
if: github.ref == 'refs/heads/main'
160113
env:
161114
DOCS_HOST: ${{ secrets.DOCS_HOST }}
162115
DOCS_PATH: ${{ secrets.DOCS_PATH }}

.github/workflows/maintenance-fast.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,10 @@ run-name: ${{ github.event.inputs.commit_sha && format('Manual Test - {0}', gith
44
on:
55
push:
66
branches: ['*.*.x']
7-
workflow_dispatch:
8-
inputs:
9-
commit_sha:
10-
description: 'Specific commit SHA to test (optional - defaults to latest)'
11-
required: false
12-
type: string
137

148
jobs:
159
fast-impacted:
16-
if: ${{ contains(github.event.head_commit.message, '(cherry picked from commit') || github.event_name == 'workflow_dispatch' }}
10+
if: contains(github.event.head_commit.message, '(cherry picked from commit')
1711
runs-on: ubuntu-latest
1812
permissions:
1913
contents: read
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>org.springframework.ai</groupId>
8+
<artifactId>spring-ai-parent</artifactId>
9+
<version>1.1.0-SNAPSHOT</version>
10+
<relativePath>../../../pom.xml</relativePath>
11+
</parent>
12+
<artifactId>spring-ai-autoconfigure-mcp-server-common</artifactId>
13+
<packaging>jar</packaging>
14+
<name>Spring AI MCP Server Common Auto Configuration for STDIO, SSE and Streamable-HTTP</name>
15+
<description>Spring AI MCP Server Common Auto Configuration for STDIO, SSE and Streamable-HTTP</description>
16+
<url>https://github.com/spring-projects/spring-ai</url>
17+
18+
<scm>
19+
<url>https://github.com/spring-projects/spring-ai</url>
20+
<connection>git://github.com/spring-projects/spring-ai.git</connection>
21+
<developerConnection>[email protected]:spring-projects/spring-ai.git</developerConnection>
22+
</scm>
23+
24+
<dependencies>
25+
26+
<dependency>
27+
<groupId>org.springframework.ai</groupId>
28+
<artifactId>spring-ai-autoconfigure-mcp-server-properties</artifactId>
29+
<version>${project.parent.version}</version>
30+
</dependency>
31+
32+
<dependency>
33+
<groupId>org.springframework.boot</groupId>
34+
<artifactId>spring-boot-starter</artifactId>
35+
</dependency>
36+
37+
<dependency>
38+
<groupId>org.springframework.ai</groupId>
39+
<artifactId>spring-ai-mcp</artifactId>
40+
<version>${project.parent.version}</version>
41+
<optional>true</optional>
42+
</dependency>
43+
44+
<dependency>
45+
<groupId>org.springframework</groupId>
46+
<artifactId>spring-web</artifactId>
47+
<optional>true</optional>
48+
</dependency>
49+
50+
<dependency>
51+
<groupId>org.springframework.boot</groupId>
52+
<artifactId>spring-boot-configuration-processor</artifactId>
53+
<optional>true</optional>
54+
</dependency>
55+
56+
<dependency>
57+
<groupId>org.springframework.boot</groupId>
58+
<artifactId>spring-boot-autoconfigure-processor</artifactId>
59+
<optional>true</optional>
60+
</dependency>
61+
62+
<!-- test dependencies -->
63+
64+
<dependency>
65+
<groupId>org.springframework.ai</groupId>
66+
<artifactId>spring-ai-test</artifactId>
67+
<version>${project.parent.version}</version>
68+
<scope>test</scope>
69+
</dependency>
70+
71+
<dependency>
72+
<groupId>net.javacrumbs.json-unit</groupId>
73+
<artifactId>json-unit-assertj</artifactId>
74+
<version>${json-unit-assertj.version}</version>
75+
<scope>test</scope>
76+
</dependency>
77+
78+
</dependencies>
79+
80+
</project>

0 commit comments

Comments
 (0)