A Spring Boot application that provides an AI-powered chat client with Model Context Protocol (MCP) server integration, featuring Cloud Foundry Single Sign-On (CF-SSO) authentication.
- 🔐 CF-SSO Authentication: Seamless integration with Cloud Foundry Single Sign-On
- 🤖 AI Chat Interface: Powered by Spring AI with support for multiple LLM providers
- 🔌 MCP Server Integration: Model Context Protocol server connectivity
- 💾 Memory Management: Persistent conversation history with vector storage
- 📄 Document Processing: PDF document analysis and processing
- 🌐 Multilingual Support: English and Hebrew language support
- 📱 Responsive UI: Modern, mobile-friendly interface
User → Landing Page → CF-SSO Login → Welcome Page → Chat Interface
- Backend: Spring Boot 3.5.3, Spring Security, Spring AI
- Frontend: Angular, HTML5, CSS3, JavaScript
- Authentication: OAuth2/OIDC with CF-SSO via java-cfenv
- Database: PostgreSQL with pgvector for embeddings
- Deployment: Cloud Foundry with java-buildpack
- Java 21+
- Maven 3.6+
- Node.js 18+ (for frontend build)
- PostgreSQL database
- Cloud Foundry CLI
- CF-SSO service instance
git clone https://github.com/0pens0/cf-mcp-client.git
cd cf-mcp-client
git checkout feature/landing-page-ssoCreate a PostgreSQL database:
CREATE DATABASE mydb;
CREATE USER myuser WITH PASSWORD 'mypassword';
GRANT ALL PRIVILEGES ON DATABASE mydb TO myuser;Create application-local.yaml:
spring:
datasource:
url: jdbc:postgresql://localhost:5432/mydb
username: myuser
password: mypassword
driver-class-name: org.postgresql.Driver
jpa:
hibernate:
ddl-auto: update
# Optional: GitHub OAuth2 for local development
spring:
security:
oauth2:
client:
registration:
github:
client-id: ${GITHUB_CLIENT_ID}
client-secret: ${GITHUB_CLIENT_SECRET}
scope: read:user, user:email
provider:
github:
authorization-uri: https://github.com/login/oauth/authorize
token-uri: https://github.com/login/oauth/access_token
user-info-uri: https://api.github.com/user
user-name-attribute: id# Build the application
mvn clean package -DskipTests
# Run locally
java -jar target/cf-mcp-client-1.5.1.jar --spring.profiles.active=local- CF-SSO service instance available in your Cloud Foundry space
- PostgreSQL service instance (optional, can use external database)
# Create CF-SSO service instance
cf create-service p-identity cf-sso-service
# Optional: Create PostgreSQL service
cf create-service postgresql-db shared postgres-service# Deploy to Cloud Foundry
cf push cf-mcp-client-sso -f manifest.yml# Bind CF-SSO service
cf bind-service cf-mcp-client-sso cf-sso-service
# Optional: Bind PostgreSQL service
cf bind-service cf-mcp-client-sso postgres-service
# Restart application to pick up service bindings
cf restart cf-mcp-client-ssoThe application uses java-cfenv-boot-pivotal-sso for automatic OAuth2 configuration:
<dependency>
<groupId>io.pivotal.cfenv</groupId>
<artifactId>java-cfenv-boot-pivotal-sso</artifactId>
<version>3.5.0</version>
</dependency>This automatically configures:
- OAuth2 client registration with ID
sso - Authorization, token, and user info URIs
- Client ID and secret from service binding
- Proper scopes and redirect URIs
If automatic configuration doesn't work, you can manually configure OAuth2 in application.yaml:
spring:
security:
oauth2:
client:
registration:
cf-sso:
client-id: ${CF_SSO_CLIENT_ID}
client-secret: ${CF_SSO_CLIENT_SECRET}
scope: openid, profile
authorization-grant-type: authorization_code
redirect-uri: "{baseUrl}/login/oauth2/code/{registrationId}"
provider:
cf-sso:
authorization-uri: ${CF_SSO_AUTH_URI}
token-uri: ${CF_SSO_TOKEN_URI}
user-info-uri: ${CF_SSO_USER_INFO_URI}
user-name-attribute: user_name
jwk-set-uri: ${CF_SSO_JWK_SET_URI}/- Landing page/login.html- Login page/login- OAuth2 login redirect/auth/provider- Get active authentication provider/auth/status- Get authentication status
/welcome- Post-login welcome page/chat- Chat interface (if implemented)/document/**- Document processing endpoints
/oauth2/authorization/sso- CF-SSO authorization/oauth2/authorization/github- GitHub authorization (fallback)/login/oauth2/code/sso- CF-SSO callback/login/oauth2/code/github- GitHub callback
Problem: Login button uses wrong registration ID
Solution: Update login button to use /oauth2/authorization/sso instead of /oauth2/authorization/cf-sso
Problem: CF-SSO JWK Set URI returns invalid data
Solution: Use java-cfenv auto-configuration instead of manual configuration
Problem: Multiple controllers handle the same endpoint
Solution: Remove conflicting mappings or use different endpoint paths
Problem: Bean conflicts or missing dependencies
Solution: Check logs for specific error messages and resolve conflicts
Enable debug logging:
logging:
level:
org.springframework.security: DEBUG
org.springframework.security.oauth2: DEBUG
io.pivotal.cfenv: DEBUGLoginController: Handles OAuth2 login redirects and provider selectionWelcomeController: Displays post-login welcome page with user infoAuthController: Provides authentication status and provider informationWebController: Serves static pages and handles root redirects
SecurityConfig: Configures Spring Security with OAuth2 login- Auto-configuration: Uses java-cfenv for CF-SSO integration
- Dynamic provider selection: Supports CF-SSO and GitHub OAuth2
login.html: Login page with dynamic provider selectionwelcome.html: Thymeleaf template for welcome page- Angular components: Chat interface and document processing
- Fork the repository
- Create a feature branch:
git checkout -b feature/new-feature - Commit changes:
git commit -am 'Add new feature' - Push to branch:
git push origin feature/new-feature - Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Spring Boot and Spring Security teams for excellent OAuth2 support
- Cloud Foundry team for CF-SSO service
- java-cfenv project for automatic service binding configuration
- Spring AI team for AI integration capabilities
For issues and questions:
- Create an issue in the GitHub repository
- Check the troubleshooting section above
- Review Cloud Foundry and CF-SSO documentation
Built with ❤️ for the Cloud Foundry and Spring communities