-
Notifications
You must be signed in to change notification settings - Fork 793
Invalid Automatic-Module-Name in mcp-core #722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid Automatic-Module-Name in mcp-core #722
Conversation
cdivilly
commented
Dec 12, 2025
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
commented
Dec 12, 2025
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.
I've revised this PR to address the split package issue.
- Move automatic module name generation to
maven-jar-plugin. Ensures all modules have a valid name - Remove OSGi config from
mcp-core.bnd-maven-plugincauses the classes inmcp-jsonto be duplicated intomcp-core, which then causes split-package issue. - I've prepared a separate branch that would restore the OSGi support, but I am not in favour of merging it as it leads to a bifurcated dependency graph. The branch is here: main...cdivilly:mcp-java-sdk:fix/mcp-osgi-support
6fb0ef4 to
a4af515
Compare
...nfiguration, as causes duplicate classes, causing split package problem across mcp-json and mcp-core.
a4af515 to
1a2fb85
Compare
Uh oh!
There was an error while loading. Please reload this page.
Fixes #560
build-helper-maven-pluginto generate a Maven property namedautomatic.module.namegenerated from${project.groupId}.${project.artifactId}, whilst ensuring the value is a syntactically valid Java Module name, by replacing any-characters with.charactersAutomatic-Module-Namein./mcp-core/pom.xmlbnd-maven-pluginconfiguration which was generating a value with an invalid value (Java Module names cannot contain the-character)./pom.xmlmaven-jar-pluginconfiguration to addAutomatic-Module-Nameproperty to the JAR manifest. Doing this here, ensures each sub-project JAR has a valid automatic module nameMotivation and Context
In versions 0.12.1 and older, the SDK consisted of a single module,
mcp. TheAutomatic-Module-Namemanifest attribute was generated by thebnd-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-jsonetc. Note the addition of the-character in the artifactId. The existing logic for generatingAutomatic-Module-Namewas not updated, resulting in syntactically invalid values being generated for the value, as Java module names are not allowed contain the-character:With the changes described above, this becomes:
How Has This Been Tested?
META/MANIFEST.MFin each jar is a valid Java module nameBreaking Changes
Types of changes
Checklist
Additional context
org.codehaus.mojo:build-helper-maven-pluginis added to the rootpom.xml. This purpose of this plugin is to generate and rewrite the value of${automatic.module.name}property into a syntactically valid Java module nameAutomatic-Module-Nameis moved from thebnd-maven-pluginconfiguration to themaven-jar-pluginconfiguration, so it can be uniformly applied to all sub-modules.