refactor: rename artifacts and restructure modules
- Rename spring-ai-mcp-core to mcp for simpler artifact naming - Rename spring-ai-mcp-spring to spring-ai-mcp for clarity - Rename parent artifact from spring-ai-mcp to mcp-parent - Update artifact references in pom files and documentation - Update directory structure and paths in GitHub workflow Resolves #31 chore: improve module descriptions and update dependencies - Update parent pom description to better reflect overall project scope - Update mcp module description to detail core Java SDK capabilities - Update spring-ai-mcp module description to emphasize Spring integration features - Update dependency versions to stable releases: * JUnit: 5.11.3 -> 5.10.2 * Jackson: 2.18.2 -> 2.17.0
This commit is contained in:
parent
2ea5527ade
commit
12fd8e51f3
3 changed files with 92 additions and 109 deletions
49
spring-ai-mcp/README.md
Normal file
49
spring-ai-mcp/README.md
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
# Spring AI MCP Spring
|
||||
|
||||
Spring Integration module for Model Control Protocol (MCP) that provides Spring-specific functionality for working with MCP clients.
|
||||
|
||||
## Overview
|
||||
|
||||
The `spring-ai-mcp` module is part of the [Spring AI MCP](https://github.com/spring-projects-experimental/spring-ai-mcp) project. It provides Spring Framework integration for the Model Control Protocol (MCP), enabling seamless integration of MCP functionality within Spring applications.
|
||||
|
||||
## Features
|
||||
|
||||
- Spring integration for MCP clients
|
||||
- Function callback implementation for tool invocations
|
||||
- Seamless integration with Spring AI's function calling capabilities
|
||||
|
||||
## Main Components
|
||||
|
||||
### McpFunctionCallback
|
||||
|
||||
The `McpFunctionCallback` class is the primary component of this module. It implements Spring AI's `FunctionCallback` interface and provides:
|
||||
|
||||
- Integration between Spring AI's function calling system and MCP tools
|
||||
- Automatic conversion between JSON and Java objects for tool arguments
|
||||
- Synchronous tool execution support
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
To use this module, add the following dependency to your Maven project:
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>org.springframework.experimental</groupId>
|
||||
<artifactId>spring-ai-mcp</artifactId>
|
||||
<version>0.2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0).
|
||||
|
||||
## Links
|
||||
|
||||
- [GitHub Repository](https://github.com/spring-projects-experimental/spring-ai-mcp)
|
||||
- [Issue Tracker](https://github.com/spring-projects-experimental/spring-ai-mcp/issues)
|
||||
|
||||
## Contributing
|
||||
|
||||
This is an experimental Spring project. Contributions are welcome! Please refer to the main project's contribution guidelines.
|
||||
35
spring-ai-mcp/pom.xml
Normal file
35
spring-ai-mcp/pom.xml
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.experimental</groupId>
|
||||
<artifactId>mcp-parent</artifactId>
|
||||
<version>0.2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>spring-ai-mcp</artifactId>
|
||||
<name>Spring AI MCP</name>
|
||||
<description>Spring Framework integration for Model Context Protocol (MCP), providing Spring AI function calling capabilities and Spring-friendly abstractions for MCP clients and MCP servers</description>
|
||||
<url>https://github.com/spring-projects-experimental/spring-ai-mcp</url>
|
||||
|
||||
<scm>
|
||||
<url>https://github.com/spring-projects-experimental/spring-ai-mcp</url>
|
||||
<connection>git://github.com/spring-projects-experimental/spring-ai-mcp.git</connection>
|
||||
<developerConnection>git@github.com:spring-projects-experimental/spring-ai-mcp.git</developerConnection>
|
||||
</scm>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-core</artifactId>
|
||||
<version>${spring-ai.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.experimental</groupId>
|
||||
<artifactId>mcp</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* Copyright 2024-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.mcp.spring;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.ai.mcp.client.McpSyncClient;
|
||||
import org.springframework.ai.mcp.spec.McpSchema.CallToolRequest;
|
||||
import org.springframework.ai.mcp.spec.McpSchema.CallToolResult;
|
||||
import org.springframework.ai.mcp.spec.McpSchema.Tool;
|
||||
|
||||
import org.springframework.ai.model.ModelOptionsUtils;
|
||||
import org.springframework.ai.model.function.FunctionCallback;
|
||||
|
||||
/**
|
||||
* @author Christian Tzolov
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
public class McpFunctionCallback implements FunctionCallback {
|
||||
|
||||
// TODO: revisit function calling as well to handle the async case
|
||||
private final McpSyncClient mcpClient;
|
||||
|
||||
private final Tool tool;
|
||||
|
||||
public McpFunctionCallback(McpSyncClient clientSession, Tool tool) {
|
||||
this.mcpClient = clientSession;
|
||||
this.tool = tool;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.tool.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return this.tool.description();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInputTypeSchema() {
|
||||
return ModelOptionsUtils.toJsonString(this.tool.inputSchema());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String call(String functionInput) {
|
||||
Map<String, Object> arguments = ModelOptionsUtils.jsonToMap(functionInput);
|
||||
CallToolResult response = this.mcpClient.callTool(new CallToolRequest(this.getName(), arguments));
|
||||
// Todo handle errors
|
||||
return ModelOptionsUtils.toJsonString(response.content());
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in a new issue