MCPcopy Index your code
hub / github.com/codeaashu/claude-code / getProjectMcpConfigsFromCwd

Function getProjectMcpConfigsFromCwd

src/services/mcp/config.ts:843–881  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

841 * @returns Servers with scope information and any validation errors from current directory's .mcp.json
842 */
843export function getProjectMcpConfigsFromCwd(): {
844 servers: Record<string, ScopedMcpServerConfig>
845 errors: ValidationError[]
846} {
847 // Check if project source is enabled
848 if (!isSettingSourceEnabled('projectSettings')) {
849 return { servers: {}, errors: [] }
850 }
851
852 const mcpJsonPath = join(getCwd(), '.mcp.json')
853
854 const { config, errors } = parseMcpConfigFromFilePath({
855 filePath: mcpJsonPath,
856 expandVars: true,
857 scope: 'project',
858 })
859
860 // Missing .mcp.json is expected, but malformed files should report errors
861 if (!config) {
862 const nonMissingErrors = errors.filter(
863 e => !e.message.startsWith('MCP config file not found'),
864 )
865 if (nonMissingErrors.length > 0) {
866 logForDebugging(
867 `MCP config errors for ${mcpJsonPath}: ${jsonStringify(nonMissingErrors.map(e => e.message))}`,
868 { level: 'error' },
869 )
870 return { servers: {}, errors: nonMissingErrors }
871 }
872 return { servers: {}, errors: [] }
873 }
874
875 return {
876 servers: config.mcpServers
877 ? addScopeToServers(config.mcpServers, 'project')
878 : {},
879 errors: errors || [],
880 }
881}
882
883/**
884 * Get all MCP configurations from a specific scope

Callers 2

addMcpConfigFunction · 0.85
removeMcpConfigFunction · 0.85

Calls 6

isSettingSourceEnabledFunction · 0.85
getCwdFunction · 0.85
logForDebuggingFunction · 0.85
jsonStringifyFunction · 0.85
addScopeToServersFunction · 0.85

Tested by

no test coverage detected