Skip to content

Repository files navigation

tinystruct MCP project

tinystruct MCP is a demonstration project that showcases how to develop Model Context Protocol (MCP) tools using the tinystruct framework. It provides a modular Java-based MCP server with built-in tools for file system management and GitHub operations.

This project is designed to bridge the gap between Large Language Models (LLMs) and external systems, enabling AI agents to interact with the physical file system and version control systems securely and efficiently.


Key Features

  • Modular Architecture: Built with Maven, allowing for easy expansion and isolation of tool sets.
  • Annotation-Driven: Simplify tool development using @Action and @Argument annotations for automatic schema generation.
  • Ready-to-Use Tools: Includes robust implementations for Git, GitHub API, and local FileSystem operations.
  • Extensible Design: Inherits the flexibility of the tinystruct framework for building high-performance Java applications.
  • Standardized Communication: Uses org.tinystruct.data.component.Builder for consistent JSON-based interaction.

Project Structure

The project is organized into submodules, each representing a specific domain of tools:

  • github/: Implements Git operations (clone, pull, push, status) and GitHub API integrations (issues, PRs, actions).
  • filesystem/: Provides comprehensive local file system management (read, write, copy, move, delete, list).
  • database/: Provides database connectivity and operations (query, insert, update, delete, describe).
  • websearch/: Provides web search capabilities using DuckDuckGo Instant Answer API.
  • bin/: Contains scripts for server management and dispatching commands.

Getting Started

Prerequisites

  • Java 17 or higher
  • Maven 3.8+

1. Build the Project

Clone the repository and build the modules using Maven:

git clone https://github.com/tinystruct/tinystruct-mcp.git
cd tinystruct-mcp
mvn clean install

2. Start the MCP Server

You can start the server programmatically or via the command line.

Command Line (CLI)

Use the bin/dispatcher (for Linux/macOS) or bin/dispatcher.cmd (for Windows) script to start the server:

# On Linux / macOS
bin/dispatcher start --import org.tinystruct.system.HttpServer --import org.tinystruct.mcp.GitHub --import org.tinystruct.mcp.FileSystem --import org.tinystruct.mcp.Database --import org.tinystruct.mcp.websearch.WebSearch --server-port 777
# On Windows
bin\dispatcher.cmd start --import org.tinystruct.system.HttpServer --import org.tinystruct.mcp.GitHub --import org.tinystruct.mcp.FileSystem --import org.tinystruct.mcp.Database --import org.tinystruct.mcp.websearch.WebSearch --server-port 777

Programmatic Startup (Java)

Include the following in your Main class to boot the server with integrated tools:

importorg.tinystruct.ApplicationContext;
importorg.tinystruct.application.Context;
importorg.tinystruct.system.ApplicationManager;
importorg.tinystruct.system.HttpServer;
importorg.tinystruct.mcp.GitHub;
importorg.tinystruct.mcp.FileSystem;
importorg.tinystruct.mcp.Database;
importorg.tinystruct.mcp.websearch.WebSearch;
publicclassMain {
publicstaticvoidmain(String[] args) {
Contextctx = newApplicationContext();
ctx.setAttribute("--server-port", "777");
ApplicationManager.init();
ApplicationManager.install(newGitHub());
ApplicationManager.install(newFileSystem());
ApplicationManager.install(newDatabase());
ApplicationManager.install(newWebSearch());
ApplicationManager.install(newHttpServer());
ApplicationManager.call("start", ctx);
}
}

Built-in Tools

GitHub Tool (github/)

ActionDescription
github/cloneClone a Git repository
github/pullPull changes from a remote repository
github/pushPush changes to a remote repository
github/statusGet the current status of a local repository
github/issuesFetch GitHub issues for a repository
github/prsFetch GitHub pull requests
github/actionsList GitHub Actions workflows

FileSystem Tool (filesystem/)

ActionDescription
filesystem/infoGet metadata about a file or directory
filesystem/existsCheck if a path exists
filesystem/readRead contents of a file (UTF-8 or Base64)
filesystem/writeWrite content to a file (overwrite or append)
filesystem/listList items in a directory
filesystem/copyCopy a file or directory
filesystem/moveMove or rename a file or directory
filesystem/deleteDelete a file or directory (recursive support)
filesystem/mkdirCreate a new directory

Database Tool (database/)

ActionDescription
db/list-tablesList all tables in the connected database
db/describeDescribe the columns and types of a specific table
db/querySELECT rows from a table with optional WHERE and LIMIT
db/insertINSERT a row into a table
db/updateUPDATE rows in a table matching a WHERE clause
db/deleteDELETE rows from a table matching a WHERE clause
db/executeExecute arbitrary SQL

WebSearch Tool (websearch/)

ActionDescription
websearch/searchPerform a web search using DuckDuckGo Instant Answer API

Developing Your Own Tools

Creating new MCP tools is straightforward. Simply extend the MCPTool class and annotate your methods.

@Action(value = "mytool/greet", description = "Greet a user", arguments = {
@Argument(key = "name", description = "User's name", type = "string")
})
publicStringgreet(Stringname) {
return"Hello, " + name + "!";
}

For a detailed guide on creating custom tools, check out DEVELOPING_TOOLS.md.


License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.

Note: MCP stands for Model Context Protocol.

About

The tinystruct-mcp is an extensible MCP server based on tinystruct framework via the Model Context Protocol (MCP).

Topics

Resources

Stars

9 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages