feat: adds a more robust and safe config editor - #184
Merged
Conversation
ChrisJBurns
marked this pull request as draft
April 14, 2025 21:18
ChrisJBurns
marked this pull request as ready for review
April 14, 2025 22:02
This commit adds a new editor layer that is more robust and less invasive when editing client config files. We now use a combination of json patches and targetting segment retrievals to avoid the failings of the JSON-CC format causing errors with the standard json marhshalling functions. Signed-off-by: ChrisJBurns <29541485+ChrisJBurns@users.noreply.github.com>
ChrisJBurns
force-pushed
the
adds-better-config-layer
branch
from
April 14, 2025 22:04
9b327a5 to
05e0f90
Compare
JAORMX
approved these changes
Apr 15, 2025
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, due to the way we perform read/write operations on the the client json config files, there are issues when reading visual studio code config files because of the JSON-CC format.
This PR not only resolves this but makes the updating of the client config files a bit better and less invasive, abstracting the complexities of these functions to the low levels.
It does this by:
json.Marshalljson.Marshall.UpsertandRemovefunction at the editor layer so we can idempotently add and remove MCP servers.MCPServersPathPrefixand theClientType, so that we can support the addition of adding specific fields to themcpServerobjects when it concerns each Client. Example, addingtypeto VS Code types as it requires them.SaveWithLockandDeleteWithLockfunctions and just hidden those in theUpsertandRemovefunctions.Todo
This PR inserts the bulk of the logic that we want, it currently works as expected, however there are some additional TODOs' left:
pathAndEditorreadConfigFiletoretrieveConfigFileMetadataor something similar to express the intent.getSupportedPaths, as there are probably better ways of achieving the same thing without having to bung theClientTypeandMCPServersPathPrefixinto thepathEditorobject. I think we should be able to just return an array ofConfigFileand then we shouldn't need to loop through theconfigPathsFindClientConfigsfunction.FindClientConfigs, the next PR should add those tests, and along with the clean up mentioned above, we should have a more decoupled and covered client config code. Theconfig_test.gomainly consisted of tests that were aimed at the editor functions itself.yamlvariant should also be added in future. However it should just be a matter of adding something similar to:Resolves
#117