sse-mcp-server-js

makc4el/sse-mcp-server-js

3.2

If you are the rightful owner of sse-mcp-server-js 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 MCP Weather Server is a TypeScript implementation that provides weather information using the National Weather Service API, utilizing SSE for real-time communication.

Tools
2
Resources
0
Prompts
0

MCP Weather and Salesforce Server (TypeScript)

A Model Context Protocol (MCP) server implementation in TypeScript that provides weather information using the National Weather Service API and Salesforce integration capabilities. This server uses SSE (Server-Sent Events) transport for real-time communication.

Features

This server provides the following MCP tools:

Weather Tools

1. get_alerts

Get active weather alerts for a US state.

Parameters:

  • state (string): Two-letter US state code (e.g., CA, NY)

Example:

{
  "name": "get_alerts",
  "arguments": {
    "state": "CA"
  }
}
2. get_forecast

Get weather forecast for a specific location.

Parameters:

  • latitude (number): Latitude of the location
  • longitude (number): Longitude of the location

Example:

{
  "name": "get_forecast",
  "arguments": {
    "latitude": 37.7749,
    "longitude": -122.4194
  }
}

Salesforce Tools

Important: For security reasons, Salesforce credentials (instanceUrl and accessToken) must be provided in each request. This allows different users to use their own Salesforce credentials and prevents storing sensitive information on the server.

1. salesforce_query_records

Query records from any Salesforce object using SOQL, including relationship queries.

Parameters:

  • instanceUrl (string): Salesforce instance URL
  • accessToken (string): Valid Salesforce access token
  • objectName (string): API name of the object
  • fields (string[]): List of fields to retrieve
  • whereClause (string, optional): WHERE clause
  • orderBy (string, optional): ORDER BY clause
  • limit (number, optional): Maximum number of records

Example:

{
  "name": "salesforce_query_records",
  "arguments": {
    "instanceUrl": "https://your-org.my.salesforce.com",
    "accessToken": "your_access_token",
    "objectName": "Account",
    "fields": ["Name", "Industry", "(SELECT Id, FirstName, LastName FROM Contacts)"],
    "whereClause": "Industry = 'Technology'",
    "limit": 10
  }
}
2. salesforce_dml_records

Perform data manipulation operations on Salesforce records.

Parameters:

  • instanceUrl (string): Salesforce instance URL
  • accessToken (string): Valid Salesforce access token
  • operation (string): One of "insert", "update", "delete", "upsert"
  • objectName (string): API name of the object
  • records (object[]): Array of records to process
  • externalIdField (string, optional): External ID field for upsert

Example:

{
  "name": "salesforce_dml_records",
  "arguments": {
    "instanceUrl": "https://your-org.my.salesforce.com",
    "accessToken": "your_access_token",
    "operation": "insert",
    "objectName": "Account",
    "records": [
      {
        "Name": "New Account",
        "Industry": "Technology"
      }
    ]
  }
}
3. salesforce_describe_object

Get detailed schema metadata for any Salesforce object.

Parameters:

  • instanceUrl (string): Salesforce instance URL
  • accessToken (string): Valid Salesforce access token
  • objectName (string): API name of the object

Example:

{
  "name": "salesforce_describe_object",
  "arguments": {
    "instanceUrl": "https://your-org.my.salesforce.com",
    "accessToken": "your_access_token",
    "objectName": "Account"
  }
}
4. salesforce_manage_field

Create or modify custom fields on any Salesforce object.

Parameters:

  • instanceUrl (string): Salesforce instance URL
  • accessToken (string): Valid Salesforce access token
  • operation (string): "create" or "update"
  • objectName (string): API name of the object
  • fieldName (string): API name for the field
  • Various field configuration options (type, label, etc.)

Example:

{
  "name": "salesforce_manage_field",
  "arguments": {
    "instanceUrl": "https://your-org.my.salesforce.com",
    "accessToken": "your_access_token",
    "operation": "create",
    "objectName": "Account",
    "fieldName": "Customer_Rating",
    "type": "Picklist",
    "label": "Customer Rating",
    "picklistValues": [
      {"label": "Hot", "isDefault": true},
      {"label": "Warm"},
      {"label": "Cold"}
    ]
  }
}
5. salesforce_manage_object

Create or modify custom objects in Salesforce.

Parameters:

  • instanceUrl (string): Salesforce instance URL
  • accessToken (string): Valid Salesforce access token
  • operation (string): "create" or "update"
  • objectName (string): API name for the object
  • Various object configuration options (label, sharing model, etc.)

Example:

{
  "name": "salesforce_manage_object",
  "arguments": {
    "instanceUrl": "https://your-org.my.salesforce.com",
    "accessToken": "your_access_token",
    "operation": "create",
    "objectName": "Customer_Feedback",
    "label": "Customer Feedback",
    "pluralLabel": "Customer Feedbacks",
    "nameFieldType": "AutoNumber",
    "nameFieldFormat": "FB-{0000}"
  }
}

📚 Documentation

  • - Detailed installation instructions and troubleshooting
  • - Quick start guide to get running fast
  • - Complete reference for all npm scripts
  • - Project overview and comparison with Python version

Installation

# Install dependencies
npm install

# Verify setup (runs automatically)
npm run verify

See for detailed installation instructions.

Usage

Development Mode (Recommended)

Run the server with hot reload:

npm run dev

The server starts on http://localhost:8080 and auto-restarts on file changes.

Production Mode

Build and start:

npm start

This automatically builds TypeScript before starting.

All Available Commands

See for a complete reference of all npm scripts.

Configuration

You can configure the server using environment variables or a .env file:

# Server Configuration
PORT=8080
HOST=0.0.0.0
NODE_ENV=production

# Optional: Default profiles for field level security
SALESFORCE_DEFAULT_PROFILES=System Administrator

# Note: Salesforce credentials (instanceUrl and accessToken) must be provided
# in each request from the MCP client for security reasons

Endpoints

The server exposes the following HTTP endpoints:

  • GET /health - Health check endpoint
  • GET /sse - SSE connection endpoint for MCP clients
  • POST /messages?sessionId=<sessionId> - Message endpoint for client requests

Deployment

Railway

This server can be deployed to Railway:

  1. Create a new Railway project
  2. Connect your repository
  3. Railway will automatically detect the package.json and build the project
  4. The server will start on the port provided by Railway's PORT environment variable

Docker

Create a Dockerfile:

FROM node:20-alpine

WORKDIR /app

COPY package*.json ./
RUN npm ci --only=production

COPY . .
RUN npm run build

EXPOSE 8080

CMD ["npm", "start"]

Build and run:

docker build -t mcp-server .
docker run -p 8080:8080 mcp-server

Testing

Test the server with curl:

# Health check
curl http://localhost:8080/health

# Connect to SSE endpoint (in one terminal)
curl -N http://localhost:8080/sse

# Send a tool call (in another terminal, use the sessionId from SSE response)
curl -X POST http://localhost:8080/messages?sessionId=<session-id> \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "tools/call",
    "params": {
      "name": "get_alerts",
      "arguments": {
        "state": "CA"
      }
    },
    "id": 1
  }'

MCP Client Configuration

To use this server with an MCP client (like Claude Desktop), add to your client configuration:

{
  "mcpServers": {
    "weather-and-salesforce": {
      "url": "http://localhost:8080/sse"
    }
  }
}

When making Salesforce tool calls, always include your Salesforce credentials in the request:

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "salesforce_query_records",
    "arguments": {
      "instanceUrl": "https://your-org.my.salesforce.com",
      "accessToken": "your_access_token",
      "objectName": "Account",
      "fields": ["Name", "Industry"]
    }
  },
  "id": 1
}

Security Note: Never store your Salesforce credentials in the server configuration. Always provide them in each request from your MCP client. This ensures that each user can use their own Salesforce credentials and sensitive information is not stored on the server.

Architecture

This server implements the MCP specification using:

  • @modelcontextprotocol/sdk: Official MCP TypeScript SDK
  • Express: HTTP server framework
  • SSE Transport: Server-Sent Events for real-time communication
  • Zod: Schema validation for tool parameters
  • National Weather Service API: Data source for weather information
  • jsforce: Salesforce API client for Node.js

License

MIT

Resources