Skip to content

Commit 47ba479

Browse files
committed
fix: build
1 parent 8b510ae commit 47ba479

File tree

9 files changed

+146
-19
lines changed

9 files changed

+146
-19
lines changed

backend/src/main/resources/application.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ management.endpoint.health.status.http-mapping.down=500
3737
management.endpoint.health.status.http-mapping.out_of_service=503
3838
management.endpoint.health.show-details=always
3939

40+
spring.ai.mcp.client.stdio.servers-configuration=classpath:mcp-servers.json
4041
embedding-token-limit=2000
4142
document-token-limit=2000
4243
image.result-size=20

mcp-server/src/main/java/ch/xxx/mcp-server/McpServerApplication.java renamed to mcp-server/src/main/java/ch/xxx/mcpserver/McpServerApplication.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
1+
/**
2+
* Copyright 2023 Sven Loesekann
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
package ch.xxx.mcpserver;
114

215
import org.springframework.ai.tool.ToolCallbackProvider;
316
import org.springframework.ai.tool.method.MethodToolCallbackProvider;
417
import org.springframework.boot.SpringApplication;
518
import org.springframework.boot.autoconfigure.SpringBootApplication;
619
import org.springframework.context.annotation.Bean;
720

8-
import ch.xxx.aidoclibchat.adapter.config.FunctionConfig;
9-
10-
/*
11-
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
12-
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
13-
*/
21+
import ch.xxx.mcpserver.config.FunctionConfig;
1422

15-
/**
16-
*
17-
* @author sven
18-
*/
1923
@SpringBootApplication
2024
public class McpServerApplication {
2125
public static void main(String[] args) {

mcp-server/src/main/java/ch/xxx/mcp-server/client/OpenLibraryRestClient.java renamed to mcp-server/src/main/java/ch/xxx/mcpserver/client/OpenLibraryRestClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
See the License for the specific language governing permissions and
1111
limitations under the License.
1212
*/
13-
package ch.xxx.aidoclibchat.adapter.client;
13+
package ch.xxx.mcpserver.client;
1414

1515
import java.net.URLEncoder;
1616
import java.nio.charset.StandardCharsets;
@@ -25,7 +25,7 @@
2525
import org.springframework.stereotype.Component;
2626
import org.springframework.web.client.RestClient;
2727

28-
import ch.xxx.aidoclibchat.domain.client.OpenLibraryClient;
28+
import ch.xxx.mcpserver.client.external.OpenLibraryClient;
2929

3030
@Component
3131
public class OpenLibraryRestClient implements OpenLibraryClient {

mcp-server/src/main/java/ch/xxx/mcp-server/client/TmdbRestClient.java renamed to mcp-server/src/main/java/ch/xxx/mcpserver/client/TmdbRestClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
See the License for the specific language governing permissions and
1111
limitations under the License.
1212
*/
13-
package ch.xxx.aidoclibchat.adapter.client;
13+
package ch.xxx.mcpserver.client;
1414

1515
import org.slf4j.Logger;
1616
import org.slf4j.LoggerFactory;
@@ -22,7 +22,7 @@
2222
import com.fasterxml.jackson.core.JsonProcessingException;
2323
import com.fasterxml.jackson.databind.ObjectMapper;
2424

25-
import ch.xxx.aidoclibchat.domain.client.TmdbClient;
25+
import ch.xxx.mcpserver.client.external.TmdbClient;
2626

2727
@Component
2828
public class TmdbRestClient implements TmdbClient {
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* Copyright 2023 Sven Loesekann
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
package ch.xxx.mcpserver.client.external;
14+
15+
import java.util.List;
16+
import java.util.function.Function;
17+
18+
import org.springframework.ai.tool.annotation.ToolParam;
19+
20+
import com.fasterxml.jackson.annotation.JsonClassDescription;
21+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
22+
import com.fasterxml.jackson.annotation.JsonInclude;
23+
import com.fasterxml.jackson.annotation.JsonInclude.Include;
24+
import com.fasterxml.jackson.annotation.JsonProperty;
25+
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
26+
27+
public interface OpenLibraryClient extends Function<OpenLibraryClient.Request, OpenLibraryClient.Response> {
28+
@JsonIgnoreProperties(ignoreUnknown = true)
29+
record Book(@JsonProperty(value = "author_name", required = false) List<String> authorName,
30+
@JsonProperty(value = "language", required = false) List<String> languages,
31+
@JsonProperty(value = "publish_date", required = false) List<String> publishDates,
32+
@JsonProperty(value = "publisher", required = false) List<String> publishers, String title, String type,
33+
@JsonProperty(value = "subject", required = false) List<String> subjects,
34+
@JsonProperty(value = "place", required = false) List<String> places,
35+
@JsonProperty(value = "time", required = false) List<String> times,
36+
@JsonProperty(value = "person", required = false) List<String> persons,
37+
@JsonProperty(value = "ratings_average", required = false) Double ratingsAverage) {
38+
}
39+
40+
@JsonInclude(Include.NON_NULL)
41+
@JsonClassDescription("OpenLibrary API request")
42+
record Request(
43+
@JsonProperty(required = false, value = "author") @ToolParam(description = "The book authors name")
44+
@JsonPropertyDescription("The book authors name") String author,
45+
@JsonProperty(required = false, value = "title") @ToolParam(description = "The book title")
46+
@JsonPropertyDescription("The book title") String title,
47+
@JsonProperty(required = false, value = "subject") @ToolParam(description = "The book subject")
48+
@JsonPropertyDescription("The book subject") String subject) {
49+
}
50+
51+
@JsonIgnoreProperties(ignoreUnknown = true)
52+
record Response(Long numFound, Long start, Boolean numFoundExact, List<Book> docs) {
53+
}
54+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* Copyright 2023 Sven Loesekann
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
package ch.xxx.mcpserver.client.external;
14+
15+
import java.util.Map;
16+
import java.util.function.Function;
17+
18+
import org.springframework.ai.tool.annotation.ToolParam;
19+
20+
/**
21+
*
22+
* @author sven
23+
*/
24+
public interface TmdbClient extends Function<TmdbClient.Request, TmdbClient.Response> {
25+
public static final Map<Integer, String> GENRE_MAP = Map.ofEntries(
26+
Map.entry(28, "Action"),
27+
Map.entry(12, "Adventure"),
28+
Map.entry(16, "Animation"),
29+
Map.entry(35, "Comedy"),
30+
Map.entry(80, "Crime"),
31+
Map.entry(99, "Documentary"),
32+
Map.entry(18, "Drama"),
33+
Map.entry(10751, "Family"),
34+
Map.entry(14, "Fantasy"),
35+
Map.entry(36, "History"),
36+
Map.entry(27, "Horror"),
37+
Map.entry(10402, "Music"),
38+
Map.entry(9648, "Mystery"),
39+
Map.entry(10749, "Romance"),
40+
Map.entry(878, "Science Fiction"),
41+
Map.entry(10770, "TV Movie"),
42+
Map.entry(53, "Thriller"),
43+
Map.entry(10752, "War"),
44+
Map.entry(37, "Western")
45+
);
46+
47+
record Request(@ToolParam(description = "The movie title") String query) {
48+
}
49+
50+
record Response(Integer page, Integer total_pages, Integer total_results, Movie[] results) { }
51+
52+
record Movie(boolean adult, String backdrop_path, Integer[] genere_ids, Long id, String original_language,
53+
String original_title, String overview, Double popularity, String poster_path, String release_date, String title,
54+
boolean video, Double vote_average, Integer vote_count) { }
55+
}

mcp-server/src/main/java/ch/xxx/mcp-server/config/FunctionConfig.java renamed to mcp-server/src/main/java/ch/xxx/mcpserver/config/FunctionConfig.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16-
package ch.xxx.aidoclibchat.adapter.config;
16+
package ch.xxx.mcpserver.config;
1717

1818
import java.util.function.Function;
1919

2020
import org.springframework.ai.tool.annotation.Tool;
2121
import org.springframework.context.annotation.Bean;
2222
import org.springframework.context.annotation.Configuration;
2323

24-
import ch.xxx.aidoclibchat.domain.client.OpenLibraryClient;
25-
import ch.xxx.aidoclibchat.domain.client.TmdbClient;
24+
import ch.xxx.mcpserver.client.external.OpenLibraryClient;
25+
import ch.xxx.mcpserver.client.external.TmdbClient;
2626

2727
@Configuration
2828
public class FunctionConfig {
@@ -43,7 +43,7 @@ public Function<OpenLibraryClient.Request, OpenLibraryClient.Response> openLibra
4343
}
4444

4545
@Bean(THE_MOVIE_DATABASE_CLIENT)
46-
@Tool(description = "Search for movies by title.")
46+
@Tool(description = "Search for movies by title.")
4747
public Function<TmdbClient.Request, TmdbClient.Response> theMovieDatabaseClient() {
4848
return this.tmdbClient::apply;
4949
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# spring.main.web-application-type=none
2+
3+
# NOTE: You must disable the banner and the console logging
4+
# to allow the STDIO transport to work !!!
5+
spring.main.banner-mode=off
6+
# logging.pattern.console=
7+
8+
# spring.ai.mcp.server.stdio=false
9+
10+
spring.ai.mcp.server.name=my-book-movie-server
11+
spring.ai.mcp.server.version=0.0.1
12+
13+
logging.file.name=./mcp-server/weather/starter-webmvc-server/target/starter-webmvc-server.log

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
rootProject.name = 'aidocumentlibrarychat'
2-
include 'frontend' , 'backend'
2+
include 'frontend' , 'backend', 'mcp-server'

0 commit comments

Comments
 (0)