mcp-server-patterns
Skill17 starsChanged 8 months agoMITView on GitHub
Use when building MCP servers for Salesforce Apex or org integration. Node/TypeScript SDK patterns — tools, resources, prompts, Zod validation, stdio vs Streamable HTTP. Do NOT use for Apex class writing or deployment.
- Installs packages
13 other projects use a version of this, 10 of them edited.
Adopted by
Most recently taken up by
- templetongroup/radiantedited, first seen Sep 17, 2026
- jamesdebatty/skillstheir own version, first seen Sep 8, 2026
- bjornjee/skillstheir own version, first seen Sep 8, 2026
- yevhens-hue/claude-skills-starter-kitedited, first seen Aug 28, 2026
- userInner/SKILLSedited, first seen Aug 18, 2026
- SamuelNDCE/claude-super-skill-libraryedited, first seen Aug 1, 2026
Other versions13 projects use a version of this.
Word for word · 0
None found.
Edited · 10
- loulanyue/awesome-claude-notes★ 27258% same
- tpavanipradeep/everything-claude-code★ 13458% same
- templetongroup/radiant★ 11353% same
- Jamkris/everything-gemini-code★ 8756% same
- yevhens-hue/claude-skills-starter-kit★ 458% same
- userInner/SKILLS★ 348% same
- JunMystery/Agent-Guidance-Python★ 254% same
- get-proofpilot/claude-skills-catalog★ 158% same
- SamuelNDCE/claude-super-skill-library★ 154% same
- mryeastcode/ClaudeCode★ 058% same
Wrote their own version · 3
- noah-sheldon/ai-dev-kit★ 13same name
- bjornjee/skills★ 2same name
- jamesdebatty/skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository116 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- asideSkill
- checkpointSkill
- configure-sccSkill
- continuous-agent-loopSkill
- mcp-server-patternsSkill
- model-routeSkill
- prompt-optimizerSkill
- refactor-cleanSkill
- resume-sessionSkill
- save-sessionSkill
- search-firstSkill
- security-scanSkill
- sessionsSkill
- sf-2gp-security-reviewSkill
- sf-agentforce-developmentSkill
- sf-agentforce-mcp-actionsSkill
- sf-apex-async-patternsSkill
- sf-apex-best-practicesSkill
- sf-apex-constraintsSkill
- sf-apex-cursorSkill
- sf-apex-enterprise-patternsSkill
- sf-apex-testingSkill
- sf-api-designSkill
- sf-approval-processesSkill
- sf-aura-developmentSkill
- sf-build-fixSkill
- sf-cli-referenceSkill
- sf-data-modelingSkill
- sf-debuggingSkill
- sf-deployment-constraintsSkill
- sf-deploymentSkill
- sf-devops-ci-cdSkill
- sf-docs-lookupSkill
- sf-e2e-testingSkill
- sf-experience-cloudSkill
- sf-flow-developmentSkill
- sf-governor-limitsSkill
- sf-harness-auditSkill
- sf-helpSkill
- sf-integrationSkill
- sf-lwc-constraintsSkill
- sf-lwc-developmentSkill
- sf-lwc-testingSkill
- sf-metadata-managementSkill
- sf-platform-events-cdcSkill
- sf-quickstartSkill
- sf-security-constraintsSkill
- sf-securitySkill
- sf-soql-constraintsSkill
- sf-soql-optimizationSkill
- sf-tdd-workflowSkill
- sf-testing-constraintsSkill
- sf-trigger-constraintsSkill
- sf-trigger-frameworksSkill
- sf-visualforce-developmentSkill
- strategic-compactSkill
- update-docsSkill
- update-platform-docsSkill
- asideSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
7 rules. 3 are common, 0 are distinctive, and 4 are very specific to this project.
3
Common
Most of the 12 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 17
Use when: implementing a new MCP server, adding tools or resources, choosing stdio vs HTTP, integrating with @salesforce/mcp, upgrading the …
- Very specific: line 24
Resources: Read-only data the model can fetch (e.g.
- Common: line 38
Keep server logic (tools + resources) independent of transport so you can plug in stdio or HTTP in the entrypoint.
- Common: line 73
Use Zod (or the SDK's preferred schema format) for input validation.
- Very specific: line 110
When @salesforce/mcp doesn't cover your use case (org-specific business logic, custom validation rules, internal APIs), build a custom MCP …
- Common: line 137
Idempotency: Prefer idempotent tools where possible so retries are safe.
- Very specific: line 139
Security: Never pass raw user input to SOQL queries — use bind variables or parameterized queries.
“Common” is measured: kept by at least 6 in 10 of the 12 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
MCP Server Patterns
The Model Context Protocol (MCP) lets AI assistants call tools, read resources, and use prompts from your server. Use this skill when building or maintaining MCP servers, or integrating with the official Salesforce MCP server. The SDK API evolves; check Context7 (query-docs for "MCP") or the official MCP documentation for current method names and signatures.
When to Use
Use when: implementing a new MCP server, adding tools or resources, choosing stdio vs HTTP, integrating with @salesforce/mcp, upgrading the SDK, or debugging MCP registration and transport issues.
How It Works
Core Concepts
- Tools: Actions the model can invoke (e.g. search, run a command). Register with
registerTool()ortool()depending on SDK version. - Resources: Read-only data the model can fetch (e.g. file contents, API responses). Register with
registerResource()orresource(). Handlers typically receive auriargument. - Prompts: Reusable, parameterised prompt templates the client can surface (e.g. in Claude Desktop). Register with
registerPrompt()or equivalent. - Transport: stdio for local clients (e.g. Claude Desktop); Streamable HTTP is preferred for remote (Cursor, cloud). Legacy HTTP/SSE is for backward compatibility.
The Node/TypeScript SDK may expose tool() / resource() or registerTool() / registerResource(); the official SDK has changed over time. Always verify against the current MCP docs or Context7.
Transport Decision Guide
| Transport | Use When | Examples |
| stdio | Local client, same machine, Claude Desktop/Code | Development, local testing |
| Streamable HTTP | Remote clients, cloud deployment, multi-user | Cursor, production APIs |
| Legacy HTTP/SSE | Backward compatibility only | Older clients |
Keep server logic (tools + resources) independent of transport so you can plug in stdio or HTTP in the entrypoint.
Examples
Install and Server Setup
npm install @modelcontextprotocol/sdk zodimport { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";
const server = new McpServer({ name: "my-server", version: "1.0.0" });
// Register a tool
server.tool(
"search-records",
"Search Salesforce records by keyword",
{ query: z.string(), objectType: z.string().default("Account") },
async ({ query, objectType }) => {
// Your implementation here
return { content: [{ type: "text", text: JSON.stringify(results) }] };
}
);
// Connect via stdio
const transport = new StdioServerTransport();
await server.connect(transport);Note: Registration API varies by SDK version — some versions use positional args
server.tool(name, description, schema, handler), others use object syntax. Check the official MCP docs or Context7 for current@modelcontextprotocol/sdksignatures.
Use Zod (or the SDK's preferred schema format) for input validation.
Salesforce MCP Integration
Official @salesforce/mcp Server
MCP config is auto-installed by npx scc-universal install (.mcp.json for Claude Code, .cursor/mcp.json for Cursor). The official @salesforce/mcp server provides these toolsets:
| Toolset | What It Does |
orgs | Org management, auth, user info |
metadata | Deploy, retrieve, list metadata types |
data | SOQL queries, record CRUD, bulk operations |
users | User management, permission sets |
testing | Run Apex tests, get coverage results |
code-analysis | PMD/scanner, code quality checks |
lwc-experts | LWC development guidance |
devops | Source tracking, scratch org operations |
Using @salesforce/mcp in Claude Code
{
"mcpServers": {
"salesforce": {
"command": "npx",
"args": ["-y", "@salesforce/mcp@latest"],
"env": {
"SF_ORG_ALIAS": "my-org"
}
}
}
}Building Custom Salesforce MCP Tools
When @salesforce/mcp doesn't cover your use case (org-specific business logic, custom validation rules, internal APIs), build a custom MCP server:
import { execFileSync } from "child_process";
server.tool(
"validate-account-hierarchy",
"Check account hierarchy depth and circular references",
{ accountId: z.string().regex(/^[a-zA-Z0-9]{15,18}$/, "Must be a valid 15- or 18-char Salesforce ID") },
async ({ accountId }) => {
const result = execFileSync("sf", [
"data", "query",
"--sobject", "Account",
"--where", `Id='${accountId}'`,
"--fields", "Id,ParentId",
"--json"
], { timeout: 30000, encoding: "utf-8" });
return { content: [{ type: "text", text: result }] };
}
);Best Practices
- Schema first: Define input schemas with Zod for every tool; document parameters and return shape.
- Input validation: Validate and sanitize all inputs before passing to SF CLI or SOQL. Never interpolate raw user input into shell commands or queries.
- Errors: Return structured errors or messages the model can interpret; avoid raw stack traces.
- Idempotency: Prefer idempotent tools where possible so retries are safe.
- Timeouts: Set explicit timeouts on
execSync/execcalls (e.g.,{ timeout: 30000 }) and on HTTP requests. - Security: Never pass raw user input to SOQL queries — use bind variables or parameterized queries. Use Named Credentials for external callouts. Validate Salesforce IDs with Zod regex (
/^[a-zA-Z0-9]{15,18}$/) before passing to SF CLI.
Official SDKs and Docs
- JavaScript/TypeScript:
@modelcontextprotocol/sdk(npm). Use Context7 with library name "MCP" for current registration and transport patterns. - Go: Official Go SDK on GitHub (
modelcontextprotocol/go-sdk). - C#: Official C# SDK for .NET.
- Salesforce MCP:
@salesforce/mcp(npm) — official Salesforce MCP server.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

