Skip to content
Merged
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
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,37 @@ HTTP `500` uses `INTERNAL_ERROR`.
`DDExternalLicenseService` is also implemented by the LM controller. Transport
resources belong to the client proxy and are released through `RestClient.close(client)`;
the shared service interface has no lifecycle methods.

## MCP function API

`apis/com.dbeaver.datadam.mcp.api` exports `DDMcpFunctionService` for desktop tool discovery and execution.
`getFunctions()` returns descriptors with `id`, display `name`, optional `description` and `List<DDMcpFunctionParameter> parameters`.
Each parameter has `name`, `type` (`STRING`, `INTEGER`, `NUMBER`, `BOOLEAN`), optional `description`, `required`,
optional `defaultValue` and optional `validValues`. Defaults and allowed values are strings interpreted according to `type`.
The MCP server builds each tool's JSON Schema `inputSchema` from these parameters.
`callFunction(DDMcpFunctionCall)` accepts `functionId` and `Map<String, Object> arguments`, and returns a JSON value
and an `error` flag; execution errors use `error=true`.
The MCP server maps object results to `structuredContent` and the flag to `isError`.
Function IDs are unique and match `[a-zA-Z0-9_.-]{1,128}`; display names are nonblank and parameter names are nonblank and unique.
Results use `JsonNull.INSTANCE` for JSON null, never a Java null.

Register the desktop implementation on its ready Remote DAM RPC endpoint:

```java
var codec = new DDRemoteDamGsonRpcCodec(new GsonBuilder()
.serializeNulls()
.setObjectToNumberStrategy(ToNumberPolicy.BIG_DECIMAL)
.create());
var registration = rpc.register(DDMcpFunctionService.SERVICE_ID, DDMcpFunctionService.class, implementation, codec);
```

The shared topic is `dbeaver.mcp.functions`. Retain the registration until the implementation is unavailable,
then close it. Both peers must use the renamed MCP contract; Java argument type names are part of RPC operation IDs.
Configure `serializeNulls()` and `ToNumberPolicy.BIG_DECIMAL` on both peers to preserve explicit null entries
and numeric precision in argument maps, including nested maps and lists. Gson's default `Object` number handling uses `Double`.

The desktop exposes only functions allowed for `MCP`/`ALL`, rechecks permissions and arguments on every call,
and enforces enabled connections and result limits. Database credentials remain on the desktop.
Remote DAM transports thrown exceptions as RPC diagnostics, not as reconstructed `DDMcpFunctionException` objects.
MCP returns a generic error for remote handler failures without exposing diagnostic stack traces.
Timeout or interruption does not guarantee remote cancellation or SQL rollback; calls are never replayed automatically.
14 changes: 14 additions & 0 deletions apis/com.dbeaver.datadam.mcp.api/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Vendor: DBeaver Corp
Bundle-Name: DataDam MCP API
Bundle-SymbolicName: com.dbeaver.datadam.mcp.api
Bundle-Version: 0.0.17.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-21
Export-Package: com.dbeaver.datadam.mcp.api.exception,
com.dbeaver.datadam.mcp.api.model,
com.dbeaver.datadam.mcp.api.service
Bundle-ActivationPolicy: lazy
Require-Bundle: org.jkiss.utils
Import-Package: com.google.gson
Automatic-Module-Name: com.dbeaver.datadam.mcp.api
4 changes: 4 additions & 0 deletions apis/com.dbeaver.datadam.mcp.api/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source.. = src/main/java
output.. = target/classes/
bin.includes = .,
META-INF/
59 changes: 59 additions & 0 deletions apis/com.dbeaver.datadam.mcp.api/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.dbeaver.datadam</groupId>
<artifactId>api</artifactId>
<version>0.0.17-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>com.dbeaver.datadam.mcp.api</artifactId>
<packaging>eclipse-plugin</packaging>
<name>DataDam MCP API</name>

<dependencies>
<dependency>
<groupId>com.dbeaver.common</groupId>
<artifactId>org.jkiss.utils</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2026 DBeaver Corp
*
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of DBeaver Corp and its suppliers, if any.
* The intellectual and technical concepts contained
* herein are proprietary to DBeaver Corp and its suppliers
* and may be covered by U.S. and Foreign Patents,
* patents in process, and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from DBeaver Corp.
*/
package com.dbeaver.datadam.mcp.api.exception;

import com.dbeaver.datadam.mcp.api.model.DDMcpFunctionErrorCode;
import com.google.gson.JsonObject;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;

public class DDMcpFunctionException extends Exception {
private final DDMcpFunctionErrorCode code;
@Nullable
private final JsonObject data;

public DDMcpFunctionException(@NotNull DDMcpFunctionErrorCode code, @NotNull String message, @Nullable JsonObject data) {
super(message);
this.code = code;
this.data = data;
}

@NotNull
public DDMcpFunctionErrorCode getCode() {
return code;
}

@Nullable
public JsonObject getData() {
return data;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2026 DBeaver Corp
*
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of DBeaver Corp and its suppliers, if any.
* The intellectual and technical concepts contained
* herein are proprietary to DBeaver Corp and its suppliers
* and may be covered by U.S. and Foreign Patents,
* patents in process, and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from DBeaver Corp.
*/
package com.dbeaver.datadam.mcp.api.model;

import org.jkiss.code.NotNull;

import java.util.Map;

public record DDMcpFunctionCall(@NotNull String functionId, @NotNull Map<String, Object> arguments) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2026 DBeaver Corp
*
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of DBeaver Corp and its suppliers, if any.
* The intellectual and technical concepts contained
* herein are proprietary to DBeaver Corp and its suppliers
* and may be covered by U.S. and Foreign Patents,
* patents in process, and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from DBeaver Corp.
*/
package com.dbeaver.datadam.mcp.api.model;

import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;

import java.util.List;

public record DDMcpFunctionDescriptor(
@NotNull String id,
@NotNull String name,
@Nullable String description,
@NotNull List<DDMcpFunctionParameter> parameters
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2026 DBeaver Corp
*
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of DBeaver Corp and its suppliers, if any.
* The intellectual and technical concepts contained
* herein are proprietary to DBeaver Corp and its suppliers
* and may be covered by U.S. and Foreign Patents,
* patents in process, and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from DBeaver Corp.
*/
package com.dbeaver.datadam.mcp.api.model;

public enum DDMcpFunctionErrorCode {
FUNCTION_NOT_FOUND,
INVALID_ARGUMENTS,
ACCESS_DENIED,
INTERNAL_ERROR
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2026 DBeaver Corp
*
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of DBeaver Corp and its suppliers, if any.
* The intellectual and technical concepts contained
* herein are proprietary to DBeaver Corp and its suppliers
* and may be covered by U.S. and Foreign Patents,
* patents in process, and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from DBeaver Corp.
*/
package com.dbeaver.datadam.mcp.api.model;

import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;

import java.util.List;

public record DDMcpFunctionParameter(
@NotNull String name,
@NotNull Type type,
@Nullable String description,
boolean required,
@Nullable String defaultValue,
@Nullable List<String> validValues
) {
public enum Type { STRING, INTEGER, NUMBER, BOOLEAN }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2026 DBeaver Corp
*
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of DBeaver Corp and its suppliers, if any.
* The intellectual and technical concepts contained
* herein are proprietary to DBeaver Corp and its suppliers
* and may be covered by U.S. and Foreign Patents,
* patents in process, and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from DBeaver Corp.
*/
package com.dbeaver.datadam.mcp.api.model;

import com.google.gson.JsonElement;
import org.jkiss.code.NotNull;

public record DDMcpFunctionResult(@NotNull JsonElement value, boolean error) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2026 DBeaver Corp
*
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of DBeaver Corp and its suppliers, if any.
* The intellectual and technical concepts contained
* herein are proprietary to DBeaver Corp and its suppliers
* and may be covered by U.S. and Foreign Patents,
* patents in process, and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from DBeaver Corp.
*/
package com.dbeaver.datadam.mcp.api.service;

import com.dbeaver.datadam.mcp.api.exception.DDMcpFunctionException;
import com.dbeaver.datadam.mcp.api.model.DDMcpFunctionCall;
import com.dbeaver.datadam.mcp.api.model.DDMcpFunctionDescriptor;
import com.dbeaver.datadam.mcp.api.model.DDMcpFunctionResult;
import org.jkiss.code.NotNull;

import java.util.List;

/**
* Remotely available MCP functions of one authenticated desktop.
*/
public interface DDMcpFunctionService {
String SERVICE_ID = "dbeaver.mcp.functions";

@NotNull
List<DDMcpFunctionDescriptor> getFunctions() throws DDMcpFunctionException;

@NotNull
DDMcpFunctionResult callFunction(@NotNull DDMcpFunctionCall call) throws DDMcpFunctionException;
}
Loading
Loading