obsidianempire/sample-mcp-server
If you are the rightful owner of sample-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The Model Context Protocol (MCP) server is a minimal server implementation that provides a `content.search` tool for fetching text content based on specified classes and index filters.
Sample MCP Server with Salesforce AgentForce Integration
A Model Context Protocol (MCP) server designed for integration with Salesforce AgentForce to provide intelligent banking service assistance. The server supports both HTTP REST API mode (for Salesforce) and MCP protocol mode (for compatible clients).
Features
- Salesforce AgentForce Integration: External Service compatible HTTP endpoints
- Banking Data Search: Standing instructions, autopayments, and service links
- Natural Language Queries: AgentForce converts conversation to structured data
- Web Test Interface: Built-in testing and debugging tools
- MCP Protocol Support: Compatible with MCP clients when needed
Quick Start
Prerequisites
- Python 3.8+
- pip package manager
- Salesforce Developer Edition org (for AgentForce integration)
- Render account (for cloud deployment)
Local Development
-
Clone the repository:
git clone <repository-url> cd sample-mcp-server -
Install dependencies:
pip install -r requirements.txt -
Run as HTTP server (for Salesforce integration):
MCP_SERVER_MODE=http PORT=10000 python src/content_mcp_server.pyThen visit: http://localhost:10000 (this is also the default mode when
MCP_SERVER_MODEis not set) -
Run as MCP server (for MCP clients only):
MCP_SERVER_MODE=mcp python src/content_mcp_server.pyInstall the optional MCP dependency when using this mode:
pip install fastmcpSet the
MCP_TRANSPORTenvironment variable to switch between transports (defaults tosse):MCP_SERVER_MODE=mcp MCP_TRANSPORT=http python src/content_mcp_server.py # HTTP transport MCP_SERVER_MODE=mcp MCP_TRANSPORT=sse python src/content_mcp_server.py # Server-sent events
Cloud Deployment (Render)
- Connect your GitHub repository to Render
- Create a new Web Service
- Configure build settings:
- Build Command:
pip install -r requirements.txt - Start Command:
python src/content_mcp_server.py - Environment Variables:
PORT=10000MCP_SERVER_MODE=http(default HTTP/REST mode for Salesforce)
- Build Command:
- Optional – MCP mode instead of HTTP:
- Add
fastmcpto your dependencies (e.g.,pip install fastmcpduring build or include it inrequirements.txt) - Change the environment variable to
MCP_SERVER_MODE=mcp - (Recommended) set
MCP_TRANSPORT=sseunless your MCP client expects HTTP transport
- Add
- Deploy and get your public URL
Salesforce AgentForce Setup
Follow the comprehensive setup guide:
Quick setup summary:
- Create Named Credential pointing to your Render URL
- Create External Service using
/api/v1/actionsendpoint - Create AgentForce agent with banking assistant template
- Add topics and link to External Service actions
- Test with sample queries
API Endpoints
HTTP REST API (Primary Usage)
GET /health- Health checkGET /- Interactive test interfacePOST /tools/call- MCP-style tool callingGET /tools/list- List available tools
Document & Index Retrieval (New)
GET /api/v1/indexes- List available index fields and example values for filteringPOST /api/v1/search- Search documents by index filters- Request body:
{"filters": {"field": ["value", ">5000"]}} - Supports exact string matches and numeric comparisons (
>,<) - Example:
{"filters": {"invoice_amount": [">5000"], "customer": ["XYY"]}}
- Request body:
GET /api/v1/documents/{doc_id}- Retrieve document content- Query param
format=text(default) orformat=raw(PDF file) - Text format returns extracted PDF content (cached under
assets/texts/)
- Query param
GET /docs- Swagger UI for interactive testing
Salesforce External Service Endpoints
GET /api/v1/actions- OpenAPI schema for External Service registrationPOST /api/v1/actions/search_content- Main search endpoint for AgentForce (banking data)GET /api/health- Service health for monitoring
MCP Protocol (Optional)
Standard MCP JSON-RPC over stdin/stdout when run without PORT environment variable (for MCP client compatibility).
Sample Data
The server includes sample documents and indexed metadata for demonstration:
- PDF Documents: Located in
assets/(000001.pdf - 000004.pdf)- Each PDF has extracted text cached in
assets/texts/ - Indexed with customer name, invoice amount, and balance
- Each PDF has extracted text cached in
- Index Fields:
customer: Acme Corp, XYY, Beta LLC, Gamma Incinvoice_amount: numeric values (2000, 4500, 6000, 7500)balance: numeric values (0, 50, 500, 1200)
Banking Service Types (Legacy Data)
The server also retains sample banking data for AgentForce compatibility:
- standing_instruction: Recurring transfers between accounts
- autopayment: Scheduled payments to external companies
- service_link: Connected external financial services
Usage Examples
Test Queries for Content Retrieval Service
# List available index fields
curl https://your-app.onrender.com/api/v1/indexes
# Find customers with invoices > 5000
curl -X POST https://your-app.onrender.com/api/v1/search \
-H "Content-Type: application/json" \
-d '{"filters": {"invoice_amount": [">5000"]}}'
# Check customer XYY's documents
curl -X POST https://your-app.onrender.com/api/v1/search \
-H "Content-Type: application/json" \
-d '{"filters": {"customer": ["XYY"]}}'
# Retrieve extracted text from a document
curl https://your-app.onrender.com/api/v1/documents/000001.pdf?format=text
# Retrieve raw PDF
curl https://your-app.onrender.com/api/v1/documents/000001.pdf?format=raw -o document.pdf
Test Queries for AgentForce (Banking Services)
"Show me autopayments for customer C123"
"Find all services for customer C123"
"What standing instructions exist for customer C123?"
"Show me closed services for customer C456"
"Find services for customer C999" (no results)
Direct API Calls (Legacy AgentForce Endpoint)
# Test the search endpoint
curl -X POST https://your-app.onrender.com/api/v1/actions/search_content \
-H "Content-Type: application/json" \
-d '{"classes": "autopayment", "customer_id": "C123"}'
# Health check
curl https://your-app.onrender.com/health
Project Structure
sample-mcp-server/
├── src/
│ └── content_mcp_server.py # Main server (MCP + HTTP)
├── docs/
│ ├── salesforce-agentforce-setup.md # Complete setup guide
│ ├── demo-guide.md # Demo instructions
│ └── demo-assets.md # Demo support materials
├── requirements.txt # Python dependencies
├── render.yaml # Render deployment config
└── README.md # This file
Architecture
Customer Query → AgentForce → External Service → MCP Server → Banking Data
← ← ← ←
- Customer asks natural language questions in AgentForce
- AgentForce interprets intent and extracts parameters
- External Service calls MCP server via HTTP with structured data
- MCP server searches banking data and returns results
- AgentForce presents results in customer-friendly language
Development
Testing
- HTTP testing: Use the built-in web interface at
/ - Salesforce testing: Use External Service test function
- AgentForce testing: Use Preview mode in Agent Builder
- MCP client testing: Use Claude Desktop or compatible MCP client (optional)
Demo Instructions
See for complete demo instructions including:
- Setup checklist
- Demo script with sample queries
- Troubleshooting common issues
- Audience-specific variations
Troubleshooting
Common Issues
-
Agent doesn't respond:
- Check if agent is active in Salesforce
- Verify MCP server is running (
/healthendpoint) - Test External Service independently
-
External Service not found:
- Ensure Named Credential is configured correctly
- Verify External Service points to correct URL
- Check OpenAPI schema is valid
-
Wrong responses:
- Verify topic action configuration in AgentForce
- Check parameter mapping in action setup
- Test MCP server directly with curl
Debug Mode
Enable debug logging by setting environment variables:
DEBUG=true python src/content_mcp_server.py
Production Considerations
Security
- Add API key authentication for production
- Implement rate limiting
- Use HTTPS for all external communications
- Audit log all banking data access
Performance
- Add caching for frequently accessed data
- Implement connection pooling for databases
- Monitor response times and set up alerting
- Scale horizontally with load balancers
Compliance
- Implement proper audit trails
- Add data retention policies
- Ensure GDPR/privacy compliance
- Regular security assessments
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Update documentation
- Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
- Issues: Report bugs and feature requests via GitHub Issues
- Documentation: Complete setup guide in folder
- Demo Support: Use for presentations