We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/adrianmikula/JakartaMigration'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
mcp-annotation-fix-summary.md•3.79 kB
# MCP Annotation Fix Summary
## Problem Statement
The `@McpTool` annotations were repeatedly enabled and then disabled because the MCP server appeared to "not work" when annotations were enabled. After researching working examples and analyzing startup logs, we discovered the root cause.
## Root Cause
**The application was failing to start** due to database initialization errors, which prevented the MCP server from ever initializing. This created the illusion that annotations were "broken" when the real problem was application startup failure.
### Evidence
From `mcp-server-output.log`:
```
HikariPool-1 - Exception during pool initialization.
org.postgresql.util.PSQLException: FATAL: database "template" does not exist
...
Application run failed
```
Spring was attempting to:
1. Initialize HikariCP connection pool
2. Run Liquibase migrations
3. Scan for JPA repositories
4. Connect to PostgreSQL database
All of this happened **before** the MCP server could initialize and scan for `@McpTool` annotations.
## Solution
### Fix #1: Enhanced Auto-Configuration Exclusions
**Updated**: `src/main/java/adrianmikula/projectname/ProjectNameApplication.java`
Added exclusions for:
- `JdbcTemplateAutoConfiguration` - Prevents JDBC template initialization
- `TransactionAutoConfiguration` - Prevents transaction manager initialization
**Updated**: `src/main/resources/application.yml`
Added exclusions for:
- `JdbcTemplateAutoConfiguration`
- `TransactionAutoConfiguration`
- `JpaRepositoriesAutoConfiguration` - Prevents Spring Data JPA repository scanning
- `RedisAutoConfiguration` - Prevents Redis initialization
- `RedisRepositoriesAutoConfiguration` - Prevents Spring Data Redis repository scanning
### Fix #2: Research-Based Configuration
Based on analysis of working examples:
- ✅ Using `spring-ai-starter-mcp-server-webmvc` (correct starter)
- ✅ Using `org.springaicommunity:mcp-annotations:0.8.0` (correct annotation package)
- ✅ Configuration uses `type: SYNC` for synchronous methods
- ✅ All tools return simple `String` types
- ✅ All tool classes are `@Component` beans
- ✅ Logging configured to use STDERR (not STDOUT)
## Testing Checklist
After applying these fixes, verify:
1. **Application Startup**
- [ ] Application starts without database connection errors
- [ ] No HikariCP initialization attempts
- [ ] No Liquibase migration attempts
- [ ] No JPA repository scanning
2. **MCP Server Initialization**
- [ ] MCP server starts successfully
- [ ] Annotation scanner processes `@McpTool` annotations
- [ ] Tools are registered with the MCP server
3. **Tool Discovery**
- [ ] Cursor can connect to MCP server
- [ ] Tools are visible in MCP Inspector
- [ ] Tools can be called successfully
## Files Changed
1. `src/main/java/adrianmikula/projectname/ProjectNameApplication.java`
- Added `JdbcTemplateAutoConfiguration` and `TransactionAutoConfiguration` to exclusions
2. `src/main/resources/application.yml`
- Added comprehensive database-related auto-configuration exclusions
3. `docs/research/mcp-annotation-research.md` (new)
- Research document comparing our implementation with working examples
4. `docs/standards/annotation-problems.md` (updated)
- Added root cause analysis section explaining the startup failure issue
## Next Steps
1. Rebuild the application: `./gradlew clean build`
2. Test startup: Run the JAR and verify no database errors
3. Test MCP connection: Verify Cursor can connect and see tools
4. Test tool execution: Verify tools can be called successfully
## References
- [Research Document](./mcp-annotation-research.md) - Detailed comparison with working examples
- [Annotation Problems Guide](../standards/annotation-problems.md) - Configuration best practices