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
24 changes: 24 additions & 0 deletions src/main/java/com/devoxx/genie/model/mcp/GitHubRepo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.devoxx.genie.model.mcp;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
* Represents a GitHub repository, typically used for marketplace entries.
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class GitHubRepo {
private String name; // Repository name (e.g., "MCPJavaFileSystem")
private String fullName; // Full name (e.g., "stephanj/MCPJavaFileSystem")
private String description; // Description from GitHub
private String htmlUrl; // URL to the repository on GitHub
private String cloneUrl; // HTTPS clone URL for git operations
private int stars; // Number of stargazers
private String updatedAt; // Last updated timestamp (formatted string)
private String defaultBranch; // Default branch (e.g., "main" or "master")
}
123 changes: 97 additions & 26 deletions src/main/java/com/devoxx/genie/model/mcp/MCPServer.java
Original file line number Diff line number Diff line change
@@ -1,56 +1,127 @@
// File: src/main/java/com/devoxx/genie/model/mcp/MCPServer.java
package com.devoxx.genie.model.mcp;

import com.intellij.util.xmlb.annotations.Property;
import com.intellij.util.xmlb.annotations.Transient;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.jetbrains.annotations.Nullable;

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;

/**
* Represents an MCP server configuration.
* Represents a configuration for an MCP server.
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class MCPServer {
/**
* Transport type for MCP communication
*/

public enum TransportType {
STDIO, // Standard I/O communication with a subprocess
HTTP_SSE // HTTP Server-Sent Events for communication
}


private boolean enabled;
private String name;
@Builder.Default
private TransportType transportType = TransportType.STDIO;
private String name;

// STDIO transport properties


// For HTTP_SSE
private String sseUrl;

// For STDIO
private String command;
private List<String> args;

// HTTP SSE transport properties
private String sseUrl;

@Builder.Default
private Map<String, String> env = new HashMap<>();

private String workingDirectory; // Optional working directory for STDIO command

private Map<String, String> env = new ConcurrentHashMap<>();

@Builder.Default
private List<String> environment = new java.util.ArrayList<>();

@Builder.Default
private boolean enabled = true;

@Builder.Default
private List<String> availableTools = new ArrayList<>();


@Builder.Default
private Map<String, String> toolDescriptions = new HashMap<>();

private List<String> availableTools = new ArrayList<>(); // List of tool names provided by the server
private Map<String, String> toolDescriptions; // Map of toolName to description
private String toolsDescription;
}

// --- New Fields for Installed Servers via Marketplace (persisted) ---
@Property(surroundWithTag = false) // Ensures it's stored directly, not wrapped
@Nullable
private String installationPathString; // Stores the Path as a String for persistence

@Property(surroundWithTag = false)
@Nullable
private String gitHubUrl; // Original GitHub URL for installed servers, for tracking provenance

@Property(surroundWithTag = false)
@Nullable
private String repositoryName; // Name of the GitHub repo, often used for local folder name

// --- Transient Runtime Fields (not persisted) ---
@Transient
private transient Process currentProcess; // The actual running process instance

@Transient
private transient volatile boolean isRunning; // Current running state of the server

@Transient
private transient StringBuilder consoleOutputBuffer = new StringBuilder(); // In-memory buffer for console output (optional, as logs go to file)

@Transient
private transient Path installationPath; // Resolved Path object from installationPathString (convenience)

/**
* Sets the installation path string and updates the transient Path object.
* This ensures the Path object is always consistent with the persisted string.
* @param installationPathString The string representation of the installation path.
*/
public void setInstallationPathString(@Nullable String installationPathString) {
this.installationPathString = installationPathString;
this.installationPath = (installationPathString != null) ? Paths.get(installationPathString) : null;
}

/**
* Returns the Path object for the installation path. If it's null but a string is present,
* it will be reconstructed.
* @return The Path object representing the installation path.
*/
public Path getInstallationPath() {
if (installationPath == null && installationPathString != null) {
installationPath = Paths.get(installationPathString);
}
return installationPath;
}

/**
* Custom equals method based on server name for uniqueness in collections.
* @param o The object to compare.
* @return True if names are equal, false otherwise.
*/
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
MCPServer mcpServer = (MCPServer) o;
return Objects.equals(name, mcpServer.name);
}

/**
* Custom hashCode method based on server name.
* @return The hash code.
*/
@Override
public int hashCode() {
return Objects.hash(name);
}
}
Loading