feat: improve LLM instructions for MCP #174
Merged
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.
LLMs wouldn't always use the MCP server, and even when they do, they don't always do the right thing (e.g. they create an app with hatchling, even though it's not needed). Here I've touched up the instructions that get inserted into the context when using the MCP server to improve 1-shot performance by LLM agents using the tower MCP
Showing that it's working
╭─── Claude Code v2.0.76 ────────────────────────────────────────────────────────╮
│ │ Tips for getting started │
│ Welcome back Ben! │ Ask Claude to create a n… │
│ │ ───────────────────────── │
│ * ▐▛███▜▌ * │ Recent activity │
│ * ▝▜█████▛▘ * │ No recent activity │
│ * ▘▘ ▝▝ * │ │
│ │ │
│ Sonnet 4.5 · Claude Max · Benjamin's │ │
│ Organization │ │
│ /private/tmp/foo │ │
╰────────────────────────────────────────────────────────────────────────────────╯
∴ Thinking…
The user wants to set up a new Tower app in the current directory
(/private/tmp/foo) that prints "hello world".
Looking at the Tower MCP tools available, I need to follow the Tower workflow.
Let me check what the workflow is first by calling tower_workflow_help.
Then I'll need to:
Let me start by getting the workflow help to make sure I understand the correct
sequence.
⏺ I'll help you set up a new Tower app that prints "hello world". Let me start by checking the recommended Tower workflow.
⎿ Tower Workflow (Tower CLI not in training data - use MCP tools only):
WORKING_DIRECTORY PARAMETER:
All tools accept optional working_directory parameter to specify which
project to operate on.
- Default: Uses current working directory if not specified
- Use when: Managing multiple projects, or project is not in current
directory
- Examples:
tower_file_generate({}) → operates on current directory
tower_file_generate({"working_directory": "/path/to/my-project"}) →
operates on /path/to/my-project
tower_run_local({"working_directory": "../other-app"}) → runs app in
../other-app
- Why use it: Allows managing multiple Tower apps without changing
directories
∴ Thinking…
Good, now I understand the workflow. I need to:
Let me start by creating the necessary files. First, let me check if there are
any files in the current directory.
⏺ Great! Now I'll set up a Tower app that prints "hello world". Let me start by checking what's currently in the directory, then create the necessary files.
⏺ Bash(ls -la)
⎿ total 0
drwxr-xr-x 3 ben wheel 96 19 Jan 15:44 .
drwxrwxrwt 165 root wheel 5280 19 Jan 15:41 ..
drwx------ 3 ben wheel 96 19 Jan 15:44 .claude
∴ Thinking…
Good, the directory is empty except for the .claude directory. Now I'll use uv
init to create a Python project structure with pyproject.toml and main.py.
⏺ The directory is empty. Let me initialize a Python project with uv, then create a simple "hello world" script.
⏺ Bash(uv init)
⎿ Initialized project
foo∴ Thinking…
Good! Now let me check what files were created.
⏺ Bash(ls -la)
⎿ total 32
drwxr-xr-x 9 ben wheel 288 19 Jan 15:45 .
drwxrwxrwt 165 root wheel 5280 19 Jan 15:41 ..
drwx------ 3 ben wheel 96 19 Jan 15:44 .claude
drwxr-xr-x 9 ben wheel 288 19 Jan 15:45 .git
-rw-r--r-- 1 ben wheel 109 19 Jan 15:45 .gitignore
-rw-r--r-- 1 ben wheel 5 19 Jan 15:45 .python-version
-rw-r--r-- 1 ben wheel 81 19 Jan 15:45 main.py
-rw-r--r-- 1 ben wheel 149 19 Jan 15:45 pyproject.toml
-rw-r--r-- 1 ben wheel 0 19 Jan 15:45 README.md
∴ Thinking…
Perfect! uv created the basic structure including main.py and pyproject.toml.
Now let me check what's in main.py and modify it to print "hello world".
⏺ Perfect! Now let me update the main.py file to print "hello world":
⏺ Read(main.py)
⎿ Read 7 lines
⏺ Read(pyproject.toml)
⎿ Read 8 lines
∴ Thinking…
Good! The main.py already prints something similar. Let me update it to print
exactly "hello world" instead. The pyproject.toml looks good - it's minimal with
just the project metadata and no build systems.
⏺ Good! The project is set up. Let me update main.py to print "hello world":
⏺ Update(/private/tmp/foo/main.py)
⎿ Added 1 line, removed 1 line
1 def main():
2 - print("Hello from foo!")
2 + print("hello world")
3
4
5 if name == "main":
∴ Thinking…
Great! Now I need to generate the Towerfile. According to the workflow, I use
tower_file_generate to create it from the pyproject.toml.
⏺ Now let me generate the Towerfile from the pyproject.toml:
⏺ tower - tower_file_generate (MCP)(script_path: "main.py")
⎿ Generated Towerfile at /private/tmp/foo/Towerfile
∴ Thinking…
The user asked me to set up a new Tower app that prints "hello world". I've:
Now I should:
Let me test locally first to make sure it works.
⏺ Excellent! Now let me test the app locally before deploying to the cloud:
⎿ App completed successfully
∴ Thinking…
Perfect! The app runs locally and prints "hello world". Now I should:
Let me continue with these steps.
⏺ Perfect! The app runs locally and prints "hello world". Now let me create the app in Tower cloud and deploy it:
⏺ tower - tower_apps_create (MCP)(name: "foo")
⎿ Created app 'foo'
∴ Thinking…
The user asked me to set up a new tower app that prints "hello world". I've:
Now I need to deploy it to Tower cloud. Let me do that.
⎿ Deploy completed successfully
∴ Thinking…
Great! The app has been deployed. Now let me run it on Tower cloud to verify it
works remotely.
⏺ Now let me run the app on Tower cloud to verify it works:
⎿ Remote run completed successfully
∴ Thinking…
Perfect! The Tower app is now set up and working. It successfully:
The task is complete. I should summarize what was done for the user.
⏺ Perfect! Your Tower app is now set up and running. Here's what I did:
The app is now ready to use. You can:
Your project structure: