Skip to content

Conversation

@fschwiet
Copy link
Contributor

@fschwiet fschwiet commented Sep 16, 2025

This is more an RFC than a pull request. I made an attempt at adding file change monitoring so SharpTools could detect when there were external changes and reload the solution. There's tests for the file monitoring component itself, and I did a comparison while using claude showing the old version would overwrite external changes and this one managed not to.

Open questions:

  • do all writes go through DocumentOperationsService.WriteFileAsync?
  • File casing is sometimes case insensitive and I haven't tried to handle that. I don't know if it'd really be an issue, maybe Roslyn and the file system's change notification will return the files original case. Windows OS is case sensitive, but WSL and Unix are not.
  • There should probably be an inactivity timeout the monitoring should shutdown so it is not causing overhead and just force SharpTools to reload the solution on the next command
  • logging messages could probably use some more thought

I also get a warning from Claude when using the MCP server, I don't know if its new or not. I don't always get the warning

SharpTools - SharpTool_LoadProject (MCP)(projectName: "MyProject")
  ⎿  ‼ Large MCP response (~11.2k tokens), this can fill up context quickly

I'm going to run with these changes awhile and see if I notice any issues. I would appreciate hearing whatever thoughts/concerns you have.

@kooshi
Copy link
Owner

kooshi commented Sep 19, 2025

This definitely handles a quirk that I hadn't really thought about addressing yet, and you've brought up a couple other points which I hadn't even considered.

I think it would be ideal if the file monitoring could re-load single files instead of the whole solution, if at all possible. Some solutions take a few seconds to load each time. If you're doing a lot of collaborative editing, I imagine it would still be quite annoying.

The next issue is that after you manually edit a file, the AI would also still need to be instructed to re-read the file or relevant members so that it doesn't overwrite your changes simply based on outdated knowledge. This is still probably better than having to tell it to re-load the whole solution, but I wonder if it would be possible to inject the change somehow...

Regardless, this is definitely a direction I would like to go, as long as the UX and efficiency makes sense.

DocumentOperationsService.WriteFileAsync

Just going off memory, but yes I believe so.

Windows OS is case sensitive, but WSL and Unix are not.

You mean the opposite, right? I would expect any returned paths to be in the original case, regardless of the underlying case sensitivity.

There should probably be an inactivity timeout the monitoring should shutdown so it is not causing overhead and just force SharpTools to reload the solution on the next command

Fair point, if you leave this running as a service or something. If that's the case, it should probably unload the whole solution after a while.

I also get a warning from Claude when using the MCP server, I don't know if its new or not.

This must be new in CC. That's quite useful for some tools, but I intentionally targeted a token length of ~10k for the output of LoadProject, so this makes sense. That tool is really the magic that makes this project work.

@fschwiet
Copy link
Contributor Author

fschwiet commented Sep 19, 2025

The next issue is that after you manually edit a file, the AI would also still need to be instructed to re-read the file or relevant members so that it doesn't overwrite your changes simply based on outdated knowledge.

My intuition here is that the agent should be responsible for monitoring files and keeping their state in sync with what is the file system. That's what I'd expect an IDE to do, JetBrain's Rider does an excellent job. I can't imagine it working another way but am now curious what capabilities claude or other agents have in terms of monitoring/considering external changes.

@fschwiet
Copy link
Contributor Author

fschwiet commented Oct 3, 2025

Alright I haven't had time to work on this. One issue I have is I'm just not very familiar with how MCP tools work and how my ai agent is interacting with SharpTools. I'm going to start watching this interactions with https://github.com/HillviewCap/clog if I can figure out how to have it show SharpTools output (let me know if there is a better way). I am also curious if there are any tools to interact with an MCP server as a human to do adhoc exploration of its API.

@kooshi
Copy link
Owner

kooshi commented Oct 5, 2025

Indeed, I used https://github.com/f/mcptools when I was initially developing SharpTools.
It's a little annoying to use, as you have to pass in json strings, but it will let you call the tools manually.

It looks like it supports HTTP mode now, so I would suggest using the SSE server with it.

Otherwise, if you use the stdio server, you'll need to use the --load-solution arg to get it to point to something, as it only allows one tool call per mcptools invocation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants