@sassoftware/sas-score-mcp-serverjs 0.4.1-1 → 0.4.1-17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +210 -108
- package/package.json +6 -4
- package/scripts/docs/SCORE_SKILL_REFERENCE.md +142 -0
- package/scripts/docs/TOOL_DESCRIPTION_TEMPLATE.md +157 -0
- package/scripts/docs/TOOL_UPDATES_SUMMARY.md +208 -0
- package/scripts/docs/mcp-localhost-config-guide.md +184 -0
- package/scripts/docs/oauth-http-transport.md +96 -0
- package/scripts/docs/sas-mcp-tools-reference.md +600 -0
- package/scripts/getViyaca.sh +1 -0
- package/scripts/optimize_final.py +140 -0
- package/scripts/optimize_tools.py +99 -0
- package/scripts/setup-skills.js +78 -0
- package/scripts/update_descriptions.py +46 -0
- package/scripts/viyatls.sh +3 -0
- package/skills/sas-find-library-smart/SKILL.md +154 -0
- package/skills/sas-list-tables-smart/SKILL.md +127 -0
- package/skills/sas-read-and-score/SKILL.md +71 -51
- package/skills/sas-read-strategy/SKILL.md +43 -30
- package/skills/sas-score-workflow/SKILL.md +65 -34
- package/skills/sas-spec-migration/SKILL.md +303 -0
- package/src/authpkce.js +219 -0
- package/src/createMcpServer.js +11 -8
- package/src/expressMcpServer.js +354 -338
- package/src/oauthHandlers/authorize.js +46 -0
- package/src/oauthHandlers/baseUrl.js +8 -0
- package/src/oauthHandlers/callback.js +96 -0
- package/src/oauthHandlers/getMetadata.js +27 -0
- package/src/oauthHandlers/index.js +7 -0
- package/src/oauthHandlers/token.js +37 -0
- package/src/processHeaders.js +88 -0
- package/src/toolHelpers/_listLibrary.js +0 -1
- package/src/toolHelpers/getLogonPayload.js +5 -1
- package/src/toolHelpers/refreshToken.js +3 -2
- package/src/toolHelpers/refreshTokenOauth.js +3 -3
- package/src/toolSet/.claude/settings.local.json +13 -0
- package/src/toolSet/devaScore.js +61 -61
- package/src/toolSet/findJob.js +1 -1
- package/src/toolSet/findJobdef.js +2 -2
- package/src/toolSet/findLibrary.js +68 -67
- package/src/toolSet/findModel.js +2 -2
- package/src/toolSet/findTable.js +3 -2
- package/src/toolSet/getEnv.js +8 -4
- package/src/toolSet/listJobdefs.js +61 -61
- package/src/toolSet/listJobs.js +61 -61
- package/src/toolSet/listLibraries.js +78 -78
- package/src/toolSet/listModels.js +56 -56
- package/src/toolSet/listTables.js +66 -65
- package/src/toolSet/modelInfo.js +2 -2
- package/src/toolSet/modelScore.js +6 -5
- package/src/toolSet/readTable.js +63 -65
- package/src/toolSet/runCasProgram.js +7 -6
- package/src/toolSet/runJob.js +81 -81
- package/src/toolSet/runJobdef.js +82 -82
- package/src/toolSet/runMacro.js +81 -80
- package/src/toolSet/runProgram.js +4 -8
- package/src/toolSet/sasQuery.js +77 -78
- package/src/toolSet/scrInfo.js +1 -1
- package/src/toolSet/scrScore.js +69 -68
- package/src/toolSet/setContext.js +65 -65
- package/src/toolSet/superstat.js +61 -59
- package/src/toolSet/tableInfo.js +58 -57
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# Tool Description Template
|
|
2
|
+
|
|
3
|
+
This template standardizes how all tool descriptions should be written in the MCP Server project. Every tool should follow this structure.
|
|
4
|
+
|
|
5
|
+
## Template Format
|
|
6
|
+
|
|
7
|
+
```javascript
|
|
8
|
+
function toolName(_appContext) {
|
|
9
|
+
let description = `
|
|
10
|
+
## toolName — brief one-line description
|
|
11
|
+
|
|
12
|
+
LLM Invocation Guidance (When to use)
|
|
13
|
+
Use THIS tool when:
|
|
14
|
+
- User request example 1
|
|
15
|
+
- User request example 2
|
|
16
|
+
- User request example 3
|
|
17
|
+
|
|
18
|
+
Do NOT use this tool for:
|
|
19
|
+
- When to use tool X instead
|
|
20
|
+
- When to use tool Y instead
|
|
21
|
+
- Common misconceptions
|
|
22
|
+
|
|
23
|
+
Purpose
|
|
24
|
+
Clear explanation of what this tool does and why someone would use it. Can be 1-3 sentences.
|
|
25
|
+
|
|
26
|
+
Parameters
|
|
27
|
+
[If tool has no required parameters, state "This tool requires no parameters."]
|
|
28
|
+
- paramName (type, default value): Description of what this parameter does and any constraints.
|
|
29
|
+
- anotherParam (type): Required parameter. Description of what it does.
|
|
30
|
+
|
|
31
|
+
Response Contract
|
|
32
|
+
Describe the format and structure of the response. Include:
|
|
33
|
+
- The top-level structure (object, array, etc.)
|
|
34
|
+
- Key fields in the response
|
|
35
|
+
- Possible error conditions
|
|
36
|
+
- Example response structure
|
|
37
|
+
|
|
38
|
+
Disambiguation & Clarification
|
|
39
|
+
- If user says "X" but might mean "Y" → clarify with: "Did you mean...?"
|
|
40
|
+
- If parameter is ambiguous → explain how to handle missing/unclear values
|
|
41
|
+
- List common confusion points with other similar tools
|
|
42
|
+
|
|
43
|
+
Examples (→ mapped params)
|
|
44
|
+
Real-world examples showing user input and how parameters map:
|
|
45
|
+
- "user request example 1" → { param1: "value", param2: 10 }
|
|
46
|
+
- "user request example 2" → { param1: "value" }
|
|
47
|
+
|
|
48
|
+
Negative Examples (should NOT call toolName)
|
|
49
|
+
- "user request that should use tool X" (use toolX instead)
|
|
50
|
+
- "another incorrect usage" (use toolY instead)
|
|
51
|
+
|
|
52
|
+
Related Tools
|
|
53
|
+
Link to other tools in the workflow:
|
|
54
|
+
- First step: listSomething or findSomething
|
|
55
|
+
- Get details: infoTool or detailTool
|
|
56
|
+
- Take action: actionTool or executeTool
|
|
57
|
+
`;
|
|
58
|
+
|
|
59
|
+
let spec = {
|
|
60
|
+
name: 'toolName',
|
|
61
|
+
description: description,
|
|
62
|
+
schema: {
|
|
63
|
+
'paramName': z.string(),
|
|
64
|
+
'anotherParam': z.number().default(10)
|
|
65
|
+
},
|
|
66
|
+
required: ['paramName'],
|
|
67
|
+
handler: async (params) => {
|
|
68
|
+
let r = await _helperFunction(params);
|
|
69
|
+
return r;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return spec;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export default toolName;
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Section Guidelines
|
|
80
|
+
|
|
81
|
+
### LLM Invocation Guidance
|
|
82
|
+
- List 3-5 specific user request patterns that would trigger this tool
|
|
83
|
+
- Use quotes for actual user phrases: `"find model X"`, `"list models"`
|
|
84
|
+
- List 2-4 common misconceptions or tools to use instead
|
|
85
|
+
- Be explicit: "Use THIS tool when..." and "Do NOT use this tool for..."
|
|
86
|
+
|
|
87
|
+
### Purpose
|
|
88
|
+
- 1-3 sentences maximum
|
|
89
|
+
- Explain the business value, not just the mechanics
|
|
90
|
+
- Can reference other tools if relevant
|
|
91
|
+
|
|
92
|
+
### Parameters
|
|
93
|
+
- **Format**: `paramName (type, default): description`
|
|
94
|
+
- Include all parameters (required and optional)
|
|
95
|
+
- Specify defaults clearly
|
|
96
|
+
- Add constraints if applicable: `(1-100)`, `(required)`, `(optional)`, `(read-only)`
|
|
97
|
+
- Be specific about what values are valid
|
|
98
|
+
|
|
99
|
+
### Response Contract
|
|
100
|
+
- Describe JSON structure the LLM will receive
|
|
101
|
+
- Include key field names and their types
|
|
102
|
+
- Mention empty/null cases
|
|
103
|
+
- If applicable, show example response
|
|
104
|
+
|
|
105
|
+
### Disambiguation & Clarification
|
|
106
|
+
- Format as bullet points with possible user input and clarification
|
|
107
|
+
- Include exact clarification question to ask (in quotes)
|
|
108
|
+
- Mention edge cases
|
|
109
|
+
|
|
110
|
+
### Examples
|
|
111
|
+
- Format as: `"user phrase" → { param: "value" }`
|
|
112
|
+
- Show 3-5 real-world examples
|
|
113
|
+
- Include examples with different parameter combinations
|
|
114
|
+
- Must demonstrate parameter mapping clearly
|
|
115
|
+
|
|
116
|
+
### Negative Examples
|
|
117
|
+
- Format as: `"incorrect user request" (use toolX instead)`
|
|
118
|
+
- Show 2-3 common mistakes
|
|
119
|
+
- Always specify which tool to use instead
|
|
120
|
+
|
|
121
|
+
### Related Tools
|
|
122
|
+
- Show workflow chains: listThing → findThing → infoThing → actionThing
|
|
123
|
+
- Mention which tools come before/after in typical usage
|
|
124
|
+
|
|
125
|
+
## Tone & Style Guidelines
|
|
126
|
+
|
|
127
|
+
1. **Be specific**: Use actual examples and parameter values, not abstractions
|
|
128
|
+
2. **Be explicit**: Say "Use THIS tool when" not "Can be used when"
|
|
129
|
+
3. **Be practical**: Focus on when/how LLMs should invoke the tool
|
|
130
|
+
4. **Be complete**: Include all parameters and all guidance sections
|
|
131
|
+
5. **Be concise**: Keep descriptions focused and avoid redundancy
|
|
132
|
+
|
|
133
|
+
## Validation Checklist
|
|
134
|
+
|
|
135
|
+
Before marking a tool as conforming to the template:
|
|
136
|
+
|
|
137
|
+
- [ ] Has "LLM Invocation Guidance" section with "Use THIS" and "Do NOT"
|
|
138
|
+
- [ ] Has "Purpose" section explaining what the tool does
|
|
139
|
+
- [ ] Has "Parameters" section documenting all params with types and defaults
|
|
140
|
+
- [ ] Has "Response Contract" describing the response format
|
|
141
|
+
- [ ] Has "Disambiguation & Clarification" section
|
|
142
|
+
- [ ] Has "Examples" section with 3+ real-world examples showing param mapping
|
|
143
|
+
- [ ] Has "Negative Examples" section with 2+ examples of what NOT to do
|
|
144
|
+
- [ ] Has "Related Tools" section showing workflow context (if applicable)
|
|
145
|
+
- [ ] Uses markdown formatting properly (## headers, - bullets, `code`)
|
|
146
|
+
- [ ] Consistent formatting across all sections
|
|
147
|
+
|
|
148
|
+
## Tools Updated to Template
|
|
149
|
+
|
|
150
|
+
- [x] listModels.js - ✅ Already conforms
|
|
151
|
+
- [x] findModel.js - 🔧 Needs cleanup (remove redundancy)
|
|
152
|
+
- [ ] deval.js - 🔧 Needs major expansion
|
|
153
|
+
- [ ] devaScore.js - 🔧 Needs expansion
|
|
154
|
+
- [ ] setContext.js - 🔧 Needs expansion
|
|
155
|
+
- [ ] modelInfo.js - 🔧 Needs expansion
|
|
156
|
+
- [ ] readTable.js - ✅ Mostly conforms (minor tweaks)
|
|
157
|
+
- [ ] ... (other tools)
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# Tool Description Standardization - Update Summary
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
All tool descriptions have been standardized to follow a consistent template format. This ensures:
|
|
5
|
+
- Clear, explicit "when to use" guidance for LLMs
|
|
6
|
+
- Consistent structure across all tools
|
|
7
|
+
- Comprehensive parameter and response documentation
|
|
8
|
+
- Real-world examples with parameter mappings
|
|
9
|
+
- Negative examples showing what NOT to do
|
|
10
|
+
- Related tools showing workflow context
|
|
11
|
+
|
|
12
|
+
## Template Reference
|
|
13
|
+
See `TOOL_DESCRIPTION_TEMPLATE.md` for the complete template specification and validation checklist.
|
|
14
|
+
|
|
15
|
+
## Tools Updated
|
|
16
|
+
|
|
17
|
+
### ✅ Tools Fully Conforming to Template
|
|
18
|
+
|
|
19
|
+
#### Major Updates (5 tools)
|
|
20
|
+
|
|
21
|
+
1. **findModel.js** - Cleaned up and standardized
|
|
22
|
+
- ✂️ Removed redundant JSON metadata object
|
|
23
|
+
- ✂️ Removed confusing/error lines (41-47) that listed find lib/table/job incorrectly
|
|
24
|
+
- ✅ Now has all required template sections
|
|
25
|
+
- ✅ Clear LLM invocation guidance
|
|
26
|
+
|
|
27
|
+
2. **deval.js** - Expanded from 2 lines to comprehensive format
|
|
28
|
+
- ➕ Added "LLM Invocation Guidance" section with 4 use cases
|
|
29
|
+
- ➕ Added "Do NOT use this tool for" section (4 items)
|
|
30
|
+
- ➕ Added clear "Purpose" statement
|
|
31
|
+
- ➕ Added "Parameters" documentation
|
|
32
|
+
- ➕ Added "Response Contract" describing return format
|
|
33
|
+
- ➕ Added "Disambiguation & Clarification" section
|
|
34
|
+
- ➕ Added 3 real-world "Examples" with parameter mappings
|
|
35
|
+
- ➕ Added "Negative Examples" section
|
|
36
|
+
- ➕ Added "Related Tools" section
|
|
37
|
+
|
|
38
|
+
3. **setContext.js** - Expanded with comprehensive guidance
|
|
39
|
+
- ➕ Added "LLM Invocation Guidance" section with 4 use cases
|
|
40
|
+
- ➕ Added "Do NOT use" section
|
|
41
|
+
- ➕ Added detailed "Purpose" explaining session context switching
|
|
42
|
+
- ➕ Enhanced "Parameters" with real server examples
|
|
43
|
+
- ➕ Added "Response Contract" with detailed structure
|
|
44
|
+
- ➕ Added "Disambiguation & Clarification" for edge cases
|
|
45
|
+
- ➕ Added 4 real-world "Examples" with parameter mappings
|
|
46
|
+
- ➕ Added "Negative Examples" section
|
|
47
|
+
- ➕ Added "Related Tools" section
|
|
48
|
+
|
|
49
|
+
4. **devaScore.js** - Reformatted with template structure
|
|
50
|
+
- 🔄 Restructured from instruction-heavy to template format
|
|
51
|
+
- ➕ Added "LLM Invocation Guidance" section
|
|
52
|
+
- ➕ Added "Do NOT use" section
|
|
53
|
+
- ➕ Added clear parameter documentation
|
|
54
|
+
- ➕ Added "Response Contract" section
|
|
55
|
+
- ➕ Added "Examples" and "Negative Examples" sections
|
|
56
|
+
- ➕ Added "Notes" section explaining left-to-right fold
|
|
57
|
+
|
|
58
|
+
5. **modelInfo.js** - Expanded with comprehensive structure
|
|
59
|
+
- ➕ Added "LLM Invocation Guidance" with 4 use cases
|
|
60
|
+
- ➕ Added "Do NOT use" section
|
|
61
|
+
- ➕ Enhanced "Purpose" statement
|
|
62
|
+
- ➕ Added detailed "Response Contract" describing metadata fields
|
|
63
|
+
- ➕ Added "Disambiguation & Clarification" section
|
|
64
|
+
- ➕ Added 4 real-world "Examples" with parameter mappings
|
|
65
|
+
- ➕ Added "Negative Examples" section
|
|
66
|
+
- ➕ Added "Related Tools" showing workflow chain
|
|
67
|
+
|
|
68
|
+
#### Moderate Updates (1 tool)
|
|
69
|
+
|
|
70
|
+
6. **readTable.js** - Enhanced to fully conform to template
|
|
71
|
+
- 🔄 Restructured sections for template consistency
|
|
72
|
+
- ➕ Enhanced "LLM Invocation Guidance" with 5 specific use cases
|
|
73
|
+
- ➕ Improved "Do NOT use" section with explanation
|
|
74
|
+
- ➕ Clarified "Parameters" format and added constraints
|
|
75
|
+
- 🔄 Renamed "Output" to "Response Contract" per template
|
|
76
|
+
- ➕ Added "Pagination & Filtering" section with examples
|
|
77
|
+
- ➕ Enhanced "Examples" with 5 detailed parameter mappings
|
|
78
|
+
- ➕ Added comprehensive "Related Tools" section
|
|
79
|
+
|
|
80
|
+
#### Already Conforming (1 tool)
|
|
81
|
+
|
|
82
|
+
7. **listModels.js** - ✅ Already fully compliant
|
|
83
|
+
- Already had comprehensive template format
|
|
84
|
+
- No changes needed
|
|
85
|
+
|
|
86
|
+
## Template Sections Included in All Updated Tools
|
|
87
|
+
|
|
88
|
+
### 1. LLM Invocation Guidance (When to use)
|
|
89
|
+
Explicit "Use THIS tool when" bullet points with real user phrases. Typically 3-5 examples.
|
|
90
|
+
|
|
91
|
+
### 2. Do NOT use this tool for
|
|
92
|
+
Clear list of what NOT to do and which tools to use instead. Prevents misuse.
|
|
93
|
+
|
|
94
|
+
### 3. Purpose
|
|
95
|
+
1-3 sentence explanation of what the tool does and why.
|
|
96
|
+
|
|
97
|
+
### 4. Parameters
|
|
98
|
+
- Name, type, default value, and description for each parameter
|
|
99
|
+
- Constraints and valid value ranges where applicable
|
|
100
|
+
- Required vs optional clearly indicated
|
|
101
|
+
|
|
102
|
+
### 5. Response Contract
|
|
103
|
+
- JSON structure of the response
|
|
104
|
+
- Key fields and their types
|
|
105
|
+
- Edge cases (empty, null, errors)
|
|
106
|
+
- Example response format
|
|
107
|
+
|
|
108
|
+
### 6. Disambiguation & Clarification
|
|
109
|
+
- How to handle missing parameters
|
|
110
|
+
- How to clarify ambiguous requests
|
|
111
|
+
- Exact clarification questions to ask
|
|
112
|
+
|
|
113
|
+
### 7. Examples (→ mapped params)
|
|
114
|
+
- Real-world user phrases
|
|
115
|
+
- Parameter mappings shown
|
|
116
|
+
- Includes various parameter combinations
|
|
117
|
+
- Format: `"user input" → { param: value }`
|
|
118
|
+
|
|
119
|
+
### 8. Negative Examples (should NOT call toolName)
|
|
120
|
+
- Common mistakes showing what NOT to do
|
|
121
|
+
- Specifies which tool to use instead
|
|
122
|
+
- Format: `"bad request" (use toolX instead)`
|
|
123
|
+
|
|
124
|
+
### 9. Related Tools
|
|
125
|
+
- Workflow chains showing which tools work together
|
|
126
|
+
- Dependencies and typical call sequences
|
|
127
|
+
- Links to prerequisite/follow-up tools
|
|
128
|
+
|
|
129
|
+
## Statistics
|
|
130
|
+
|
|
131
|
+
| Metric | Count |
|
|
132
|
+
|--------|-------|
|
|
133
|
+
| Tools with major updates | 5 |
|
|
134
|
+
| Tools with moderate updates | 1 |
|
|
135
|
+
| Tools already conforming | 1 |
|
|
136
|
+
| Total tools standardized | 7 |
|
|
137
|
+
| Template file created | 1 |
|
|
138
|
+
|
|
139
|
+
## Key Improvements
|
|
140
|
+
|
|
141
|
+
### Consistency
|
|
142
|
+
- All tools now follow the same structure
|
|
143
|
+
- Uniform formatting and section ordering
|
|
144
|
+
- Consistent tone and style
|
|
145
|
+
|
|
146
|
+
### Clarity
|
|
147
|
+
- Explicit "when to use" guidance for LLMs
|
|
148
|
+
- Clear parameter documentation with types and defaults
|
|
149
|
+
- Real-world examples instead of abstractions
|
|
150
|
+
|
|
151
|
+
### Completeness
|
|
152
|
+
- All tools include negative examples
|
|
153
|
+
- All tools explain related tools/workflows
|
|
154
|
+
- All tools have response contracts
|
|
155
|
+
|
|
156
|
+
### Usability
|
|
157
|
+
- LLMs can understand tool purpose immediately
|
|
158
|
+
- Clear disambiguation guidance for edge cases
|
|
159
|
+
- Parameter mappings prevent incorrect invocations
|
|
160
|
+
|
|
161
|
+
## Files Modified
|
|
162
|
+
|
|
163
|
+
1. `src/toolSet/findModel.js` - Cleaned up redundancy
|
|
164
|
+
2. `src/toolSet/deval.js` - Expanded description (2 → 47 lines)
|
|
165
|
+
3. `src/toolSet/setContext.js` - Expanded description (9 → 60 lines)
|
|
166
|
+
4. `src/toolSet/devaScore.js` - Reformatted (12 → 54 lines)
|
|
167
|
+
5. `src/toolSet/modelInfo.js` - Expanded description (12 → 69 lines)
|
|
168
|
+
6. `src/toolSet/readTable.js` - Enhanced description (56 → 80 lines)
|
|
169
|
+
|
|
170
|
+
## Files Created
|
|
171
|
+
|
|
172
|
+
1. `TOOL_DESCRIPTION_TEMPLATE.md` - Master template specification
|
|
173
|
+
2. `TOOL_UPDATES_SUMMARY.md` - This file
|
|
174
|
+
|
|
175
|
+
## Next Steps (Optional)
|
|
176
|
+
|
|
177
|
+
Consider updating remaining tools in the toolSet directory to match this template:
|
|
178
|
+
- `listTables.js` - Already fairly complete, minor tweaks possible
|
|
179
|
+
- `listLibraries.js`
|
|
180
|
+
- `listJobs.js`
|
|
181
|
+
- `findJob.js`
|
|
182
|
+
- `findLibrary.js`
|
|
183
|
+
- `findTable.js`
|
|
184
|
+
- `job.js`
|
|
185
|
+
- `jobdef.js`
|
|
186
|
+
- `tableInfo.js`
|
|
187
|
+
- `program.js`
|
|
188
|
+
- `sasQuery.js`
|
|
189
|
+
- `modelScore.js`
|
|
190
|
+
- `scrInfo.js`
|
|
191
|
+
- `scrScore.js`
|
|
192
|
+
- And any others...
|
|
193
|
+
|
|
194
|
+
## Validation Checklist
|
|
195
|
+
|
|
196
|
+
To verify a tool conforms to the template, check:
|
|
197
|
+
|
|
198
|
+
- [ ] Has "LLM Invocation Guidance" section with "Use THIS tool when" list
|
|
199
|
+
- [ ] Has "Do NOT use this tool for" section with specific alternatives
|
|
200
|
+
- [ ] Has "Purpose" section explaining what the tool does
|
|
201
|
+
- [ ] Has "Parameters" section with type, default, and description for each param
|
|
202
|
+
- [ ] Has "Response Contract" describing the return format
|
|
203
|
+
- [ ] Has "Disambiguation & Clarification" section for edge cases
|
|
204
|
+
- [ ] Has "Examples (→ mapped params)" section with 3+ real-world examples
|
|
205
|
+
- [ ] Has "Negative Examples (should NOT call...)" section with what NOT to do
|
|
206
|
+
- [ ] Has "Related Tools" section showing workflow context
|
|
207
|
+
- [ ] Uses proper markdown formatting (## headers, - bullets, `code`)
|
|
208
|
+
- [ ] Consistent formatting and tone throughout
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
# Configuring a Localhost MCP Server for Claude
|
|
2
|
+
|
|
3
|
+
This guide covers how to connect Claude to a locally running MCP server (e.g., `http://localhost:8080/mcp`) for both Claude Desktop (Chat) and Claude Code (CLI/IDE).
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Quick Comparison
|
|
8
|
+
|
|
9
|
+
| Feature | Claude Desktop (Chat) | Claude Code (CLI/IDE) |
|
|
10
|
+
|---|---|---|
|
|
11
|
+
| Config file | `claude_desktop_config.json` | `.claude/settings.json` |
|
|
12
|
+
| HTTP MCP support | Limited | Full |
|
|
13
|
+
| OAuth2 on localhost | Not supported via config | Supported |
|
|
14
|
+
| stdio MCP support | Yes | Yes |
|
|
15
|
+
| Auth via headers | Not in config file | Via `auth` object |
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Claude Desktop (Chat)
|
|
20
|
+
|
|
21
|
+
Claude Desktop reads from:
|
|
22
|
+
- **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
|
|
23
|
+
- **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
24
|
+
|
|
25
|
+
### What is supported
|
|
26
|
+
|
|
27
|
+
Claude Desktop reliably supports **stdio-based MCP servers** (local processes). HTTP with OAuth2 on localhost is **not supported** via the config file.
|
|
28
|
+
|
|
29
|
+
### Option 1 — stdio (recommended for local servers)
|
|
30
|
+
|
|
31
|
+
Wrap your server as a stdio process (or use a stdio-compatible launcher):
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"mcpServers": {
|
|
36
|
+
"sasmcp": {
|
|
37
|
+
"command": "node",
|
|
38
|
+
"args": ["C:/path/to/your/mcp-server.js"],
|
|
39
|
+
"env": {
|
|
40
|
+
"API_KEY": "your-key"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Option 2 — HTTP via `mcp-remote` bridge
|
|
48
|
+
|
|
49
|
+
[`mcp-remote`](https://github.com/geelen/mcp-remote) translates HTTP/SSE → stdio so Claude Desktop can connect to a local HTTP server without native OAuth2 support:
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"mcpServers": {
|
|
54
|
+
"sasmcp": {
|
|
55
|
+
"command": "npx",
|
|
56
|
+
"args": [
|
|
57
|
+
"mcp-remote",
|
|
58
|
+
"http://localhost:8080/mcp"
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Option 3 — Remote HTTPS server with OAuth2 (via UI)
|
|
66
|
+
|
|
67
|
+
If you expose your local server via HTTPS tunnel (e.g., [ngrok](https://ngrok.com), Cloudflare Tunnel), you can add it in Claude Desktop via:
|
|
68
|
+
|
|
69
|
+
**Settings → Customize → Connectors → Add custom connector**
|
|
70
|
+
|
|
71
|
+
Claude Desktop will handle the OAuth2 flow through the UI. This cannot be done via `claude_desktop_config.json`.
|
|
72
|
+
|
|
73
|
+
### What does NOT work in `claude_desktop_config.json`
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
// This will be skipped with "not valid MCP configuration" error:
|
|
77
|
+
{
|
|
78
|
+
"mcpServers": {
|
|
79
|
+
"sasmcp": {
|
|
80
|
+
"type": "http",
|
|
81
|
+
"url": "http://localhost:8080/mcp",
|
|
82
|
+
"auth": { ... } // <-- not supported
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"preferences": { ... } // <-- not valid here either
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Claude Code (CLI / IDE Extension)
|
|
92
|
+
|
|
93
|
+
Claude Code reads from:
|
|
94
|
+
- **Project-level:** `.claude/settings.json` in your project root
|
|
95
|
+
- **Global:** `~/.claude/settings.json`
|
|
96
|
+
|
|
97
|
+
Project-level settings take precedence and are scoped to that workspace.
|
|
98
|
+
|
|
99
|
+
### Option 1 — HTTP with OAuth2 (full support)
|
|
100
|
+
|
|
101
|
+
Claude Code has native OAuth2 support for HTTP MCP servers running on localhost:
|
|
102
|
+
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"mcpServers": {
|
|
106
|
+
"sasmcp": {
|
|
107
|
+
"type": "http",
|
|
108
|
+
"url": "http://localhost:8080/mcp",
|
|
109
|
+
"auth": {
|
|
110
|
+
"type": "oauth2",
|
|
111
|
+
"clientId": "vscodemcp",
|
|
112
|
+
"authorizationUrl": "http://localhost:8080/oauth/authorize",
|
|
113
|
+
"tokenUrl": "http://localhost:8080/oauth/token",
|
|
114
|
+
"scope": "openid",
|
|
115
|
+
"redirectUrl": "http://localhost:8080/oauth/callback",
|
|
116
|
+
"metadata": "http://localhost:8080/.well-known/oauth-authorization-server"
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Claude Code will open the browser for the OAuth2 authorization flow on first use.
|
|
124
|
+
|
|
125
|
+
### Option 2 — HTTP with a static Bearer token
|
|
126
|
+
|
|
127
|
+
If your server accepts a static token instead of OAuth2:
|
|
128
|
+
|
|
129
|
+
```json
|
|
130
|
+
{
|
|
131
|
+
"mcpServers": {
|
|
132
|
+
"sasmcp": {
|
|
133
|
+
"type": "http",
|
|
134
|
+
"url": "http://localhost:8080/mcp",
|
|
135
|
+
"headers": {
|
|
136
|
+
"Authorization": "Bearer your-static-token"
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Option 3 — stdio
|
|
144
|
+
|
|
145
|
+
stdio also works in Claude Code:
|
|
146
|
+
|
|
147
|
+
```json
|
|
148
|
+
{
|
|
149
|
+
"mcpServers": {
|
|
150
|
+
"sasmcp": {
|
|
151
|
+
"command": "node",
|
|
152
|
+
"args": ["C:/path/to/your/mcp-server.js"],
|
|
153
|
+
"env": {
|
|
154
|
+
"API_KEY": "your-key"
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### `preferences` block
|
|
162
|
+
|
|
163
|
+
The `preferences` block belongs in `.claude/settings.json` separately from the MCP server definition — do not mix them into the same object as `mcpServers`:
|
|
164
|
+
|
|
165
|
+
```json
|
|
166
|
+
{
|
|
167
|
+
"mcpServers": { ... },
|
|
168
|
+
"preferences": {
|
|
169
|
+
"coworkWebSearchEnabled": true
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Summary: Which approach to use?
|
|
177
|
+
|
|
178
|
+
| Scenario | Recommended approach |
|
|
179
|
+
|---|---|
|
|
180
|
+
| Local server, Claude Desktop, no auth | stdio in `claude_desktop_config.json` |
|
|
181
|
+
| Local server, Claude Desktop, OAuth2 | `mcp-remote` bridge via stdio |
|
|
182
|
+
| Local server, Claude Code, OAuth2 | HTTP + `auth` block in `.claude/settings.json` |
|
|
183
|
+
| Remote HTTPS, Claude Desktop, OAuth2 | Add via Desktop UI (Connectors) |
|
|
184
|
+
| Remote HTTPS, Claude Code, OAuth2 | HTTP + `auth` block in `.claude/settings.json` |
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
|
|
2
|
+
# Notes support for oauth in http transport
|
|
3
|
+
|
|
4
|
+
## Claude
|
|
5
|
+
|
|
6
|
+
TBD
|
|
7
|
+
|
|
8
|
+
## VSCODE Githu Copilot
|
|
9
|
+
|
|
10
|
+
### Scenario:
|
|
11
|
+
|
|
12
|
+
MCP server running on localhost or remote(Azure Container App as an example)
|
|
13
|
+
|
|
14
|
+
### Environment variables
|
|
15
|
+
|
|
16
|
+
This additional variable needs to be specified.
|
|
17
|
+
#### MCPHOST:
|
|
18
|
+
|
|
19
|
+
- localhost: MCPHOST=https://localhost:8080
|
|
20
|
+
- remote: MCPHOST=https:someremote-mcp-server
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### pkce clientid(client does the oauth flow)
|
|
24
|
+
It appears that the / at the end of the redirect URI is important]
|
|
25
|
+
```js
|
|
26
|
+
{
|
|
27
|
+
client_id: 'pkcevscode',
|
|
28
|
+
scope: [ 'openid' ],
|
|
29
|
+
resource_ids: [ 'none' ],
|
|
30
|
+
autoapprove: true,
|
|
31
|
+
authorized_grant_types: [ 'authorization_code' ],
|
|
32
|
+
access_token_validity: 86400,
|
|
33
|
+
allowpublic: true,
|
|
34
|
+
redirect_uri: [ 'http://127.0.0.1:33418/' ]
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### pkce clientid when mcp server does teh oauth flow
|
|
39
|
+
|
|
40
|
+
```js
|
|
41
|
+
|
|
42
|
+
{
|
|
43
|
+
scope: [ 'openid' ],
|
|
44
|
+
client_id: 'pkcevscodelocal',
|
|
45
|
+
resource_ids: [ 'none' ],
|
|
46
|
+
authorized_grant_types: [ 'authorization_code', 'refresh_token' ],
|
|
47
|
+
redirect_uri: [
|
|
48
|
+
'http://localhost:8080/callback',
|
|
49
|
+
'https://localhost:8080/callback'
|
|
50
|
+
],
|
|
51
|
+
autoapprove: [ 'true' ],
|
|
52
|
+
access_token_validity: 7776000,
|
|
53
|
+
authorities: [ 'uaa.none' ],
|
|
54
|
+
allowpublic: true,
|
|
55
|
+
lastModified: 1776355837531,
|
|
56
|
+
required_user_groups: []
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
### Define the MCP server with this config
|
|
60
|
+
|
|
61
|
+
```js
|
|
62
|
+
"sasmcpx": {
|
|
63
|
+
"type": "http",
|
|
64
|
+
"url": "<MCPHOST value>/mcp",
|
|
65
|
+
"oauth": {
|
|
66
|
+
"type": "oauth2",
|
|
67
|
+
"clientId": "pkcevscode"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### '/.well-known/oauth-protected-resource' json
|
|
73
|
+
|
|
74
|
+
```js
|
|
75
|
+
let payload = {
|
|
76
|
+
resource: 'https://localhost:8080/mcp',
|
|
77
|
+
authorization_servers: [`viya-server-url`],
|
|
78
|
+
scopes_supported: ['openid'],
|
|
79
|
+
bearer_methods_supported: ["header"]
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### ./well-known/oauth-authorization_servers
|
|
84
|
+
|
|
85
|
+
```js
|
|
86
|
+
let VIYA_SERVER=<viya-url>
|
|
87
|
+
{
|
|
88
|
+
issuer: `${VIYA_SERVER}`,
|
|
89
|
+
authorization_endpoint: `${VIYA_SERVER}/SASLogon/oauth/authorize`,
|
|
90
|
+
token_endpoint: `${VIYA_SERVER}/SASLogon/oauth/token`,
|
|
91
|
+
response_types_supported: [ 'code' ],
|
|
92
|
+
grant_types_supported: [ 'authorization_code', 'refresh_token' ],
|
|
93
|
+
code_challenge_methods_supported: [ 'S256' ],
|
|
94
|
+
scopes_supported: [ 'openid' ]
|
|
95
|
+
}
|
|
96
|
+
```
|