Skip to content

Conversation

@cdivilly
Copy link

Fixes #560

  • Uses build-helper-maven-plugin to generate a Maven property named automatic.module.name generated from ${project.groupId}.${project.artifactId}, whilst ensuring the value is a syntactically valid Java Module name, by replacing any - characters with . characters
  • Remove legacy configuration of Automatic-Module-Name in ./mcp-core/pom.xml bnd-maven-plugin configuration which was generating a value with an invalid value (Java Module names cannot contain the - character)
  • Modifies ./pom.xml maven-jar-plugin configuration to add Automatic-Module-Name property to the JAR manifest. Doing this here, ensures each sub-project JAR has a valid automatic module name

Motivation and Context

In versions 0.12.1 and older, the SDK consisted of a single module, mcp. The Automatic-Module-Name manifest attribute was generated by the bnd-maven-plugin. Note that the single module name does not contain any dash (-) characters.

In 0.13.0 and later, the SDK was refactored into multiple modules, mcp-core, mcp-json etc. Note the addition of the - character in the artifactId. The existing logic for generating Automatic-Module-Name was not updated, resulting in syntactically invalid values being generated for the value, as Java module names are not allowed contain the - character:

Automatic-Module-Name: io.modelcontextprotocol.sdk.mcp-core
  • This invalid module name prevents use of 0.13.0 and later versions of the SDK in any Java application that uses Java Modules.

With the changes described above, this becomes:

Automatic-Module-Name: io.modelcontextprotocol.sdk.mcp.core
  • Java module based applications can once again use the MCP SDK

How Has This Been Tested?

  • Checked the contents of META/MANIFEST.MF in each jar is a valid Java module name
  • Rebuilt the downstream application that was regressed by this issue using the rebuilt jars. Compile time error previously reported no longer occurs

Breaking Changes

No breaking changes, no change required by users.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

  • One new maven plugin: org.codehaus.mojo:build-helper-maven-plugin is added to the root pom.xml. This purpose of this plugin is to generate and rewrite the value of ${automatic.module.name} property into a syntactically valid Java module name
  • Configuring Automatic-Module-Name is moved from the bnd-maven-plugin configuration to the maven-jar-plugin configuration, so it can be uniformly applied to all sub-modules.

…matic module name. Remove OSGi based automatic module name generation
@cdivilly cdivilly changed the title Modify maven-jar-plugin config to generate syntactically correct auto… Invalid Automatic-Module-Name in mcp-core Dec 12, 2025
@cdivilly cdivilly marked this pull request as draft December 12, 2025 18:46
@cdivilly
Copy link
Author

More testing shows a split package issue. The package io.modelcontextprotocol.json is duplicated across the mcp-core and mcp-json jars. The package does not appear in the source code for mcp-core, it appears to be added in during the build process.

In Java modules, it is not permitted for the same package name to be used in more than one jar.

@cdivilly
Copy link
Author

The bnd-maven-plugin is pulling in the io.modelcontextprotocol.json package into mcp-core/target/classes

Due to the specific bnd-maven-plugin configuration in mcp-core, the class files from mcp-json are assembled into the mcp-core jar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid Automatic-Module-Name in mcp-core

1 participant