MCP Selenium server in Java
This folder contains a Java implementation of a basic Model Context Protocol (MCP) server. This server provides a set of tools for an AI agent to control a web browser using Selenium. This MCP server exposes the following tools:
open_browser: Launches a new browser instance (e.g., Chrome, Firefox).navigate_url: Navigates the open browser to a specified URL.get_browser_text: Retrieves the visible text content of the current page.close_browser: Closes the current browser instance.
Prerequisites
- Build the project:
Maven:
bash
mvn clean packageGradle:
bash
gradle clean build- Run the server:
Maven build:
bash
java -jar target/mcp-java-sdk-1.0.0.jarGradle build:
bash
java -jar build/libs/mcp-java-sdk-1.0.0.jar- Alternatively, you can debug the MCP server using the MCP Inspector:
Maven build:
bash
npx @modelcontextprotocol/inspector java -jar target/mcp-java-sdk-1.0.0.jarGradle build:
bash
npx @modelcontextprotocol/inspector java -jar build/libs/mcp-java-sdk-1.0.0.jarOutput
The server communicates via standard input/output (stdio) and is intended to be used as an MCP server by an AI client.
If you use the MCP inspector for debugging, once connected, it will display the available tools. You can now use its user interface to execute these tools.
