Skip to main content
Glama
ghiloufibg

Maven Project Generator MCP

by ghiloufibg

add_java_file

Add Java source or test files to Maven projects by providing class content, package names, and file types to extend project functionality.

Instructions

Ajouter un fichier Java au projet Maven

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
packageNameNoNom du package Java (ex: com.example.myplugin). Optionnel si le package est dans le contenu Java.
classNameNoNom de la classe Java. Optionnel si detectable depuis le contenu.
contentYesContenu complet du fichier Java
typeNoType de fichiermain
filePathNoChemin complet du fichier (optionnel, sera auto-genere si non fourni)

Implementation Reference

  • The addJavaFile function handles the logic for creating and storing a Java file in the project structure.
    async function addJavaFile(args: any) {
      const { content, type = "main" } = args;
      let { packageName, className, filePath } = args;
    
      if (!packageName || !className) {
        const extracted = extractJavaInfo(content);
        packageName = packageName || extracted.packageName;
        className = className || extracted.className;
      }
    
      if (!filePath) {
        if (!packageName || !className) {
          throw new Error("Impossible de determiner le package et la classe. Veuillez les specifier ou verifier le contenu Java.");
        }
    
        const packagePath = packageName.replace(/\./g, "/");
        filePath = `src/${type}/java/${packagePath}/${className}.java`;
      }
    
      currentProject.files[filePath] = content;
    
      return {
        content: [
          {
            type: "text",
            text: `Fichier Java ajoute avec succes!\n\n` +
                  `Fichier: ${filePath}\n` +
                  `Package: ${packageName || "N/A"}\n` +
                  `Classe: ${className || "N/A"}\n` +
                  `Type: ${type}\n\n` +
                  `Repertoires crees automatiquement dans la structure Maven.`,
          },
  • src/index.ts:217-218 (registration)
    The add_java_file tool is handled within the CallToolRequestSchema request handler using the addJavaFile function.
    case "add_java_file":
      return await addJavaFile(args);
  • The input schema definition for the add_java_file tool.
      name: "add_java_file",
      description: "Ajouter un fichier Java au projet Maven",
      inputSchema: {
        type: "object",
        properties: {
          packageName: {
            type: "string",
            description: "Nom du package Java (ex: com.example.myplugin). Optionnel si le package est dans le contenu Java.",
          },
          className: {
            type: "string",
            description: "Nom de la classe Java. Optionnel si detectable depuis le contenu.",
          },
          content: {
            type: "string",
            description: "Contenu complet du fichier Java",
          },
          type: {
            type: "string",
            description: "Type de fichier",
            enum: ["main", "test"],
            default: "main",
          },
          filePath: {
            type: "string",
            description: "Chemin complet du fichier (optionnel, sera auto-genere si non fourni)",
          },
        },
        required: ["content"],
      },
    },
    {
      name: "add_resource_file",
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool adds a Java file to a Maven project, implying a write operation, but doesn't cover permissions needed, whether it overwrites existing files, error handling, or what happens on success. This is inadequate for a mutation tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence in French that directly states the tool's purpose without any fluff or redundancy. It's appropriately sized and front-loaded, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool that performs a write operation (adding files) with no annotations and no output schema, the description is insufficient. It doesn't explain what happens after the file is added, potential side effects, or error conditions, leaving significant gaps in understanding the tool's behavior and outcomes.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, providing clear documentation for all 5 parameters. The description adds no additional parameter semantics beyond what's in the schema, so it meets the baseline of 3 where the schema handles the heavy lifting without compensating for gaps.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Ajouter' meaning 'Add') and the resource ('un fichier Java au projet Maven'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'add_any_file' or 'add_resource_file', which likely handle different file types in the same Maven project context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to choose 'add_java_file' over 'add_any_file' or 'add_resource_file', nor does it specify prerequisites or exclusions, leaving the agent to infer usage from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ghiloufibg/maven-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server