-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: implement current developer system as a separate mcp server #514
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e17a3f2
add instructions to InitializeRequest & Router trait
salman1993 9003812
add developer crate, which is a MCP server
salman1993 86af6ab
Merge remote-tracking branch 'origin/v1.0' into sm/mcp-server-developer
salman1993 a712d65
fmt
salman1993 f7a4386
fix bug in read_resource_internal for developer
salman1993 f77a9ca
Share cwd, active_resources, and file_history in DeveloperRouter with…
salman1993 afd059f
add unit tests for developer crate
salman1993 16fa6a0
use a helper to get first message text
salman1993 b5f2a59
remove errors.rs, return ToolError or ResourceError directly
salman1993 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
[package] | ||
name = "developer" | ||
version.workspace = true | ||
edition.workspace = true | ||
authors.workspace = true | ||
license.workspace = true | ||
repository.workspace = true | ||
description.workspace = true | ||
|
||
[dependencies] | ||
mcp-core = { path = "../mcp-core" } | ||
mcp-server = { path = "../mcp-server" } | ||
anyhow = "1.0.94" | ||
tokio = { version = "1", features = ["full"] } | ||
tracing = "0.1" | ||
tracing-subscriber = { version = "0.3", features = ["env-filter"] } | ||
tracing-appender = "0.2" | ||
url = "2.5" | ||
urlencoding = "2.1.3" | ||
base64 = "0.21" | ||
thiserror = "1.0" | ||
serde = { version = "1.0", features = ["derive"] } | ||
serde_json = "1.0" | ||
serde_urlencoded = "0.7" | ||
lazy_static = "1.5" | ||
kill_tree = "0.2.4" | ||
shellexpand = "3.1.0" | ||
indoc = "2.0.5" | ||
|
||
[dev-dependencies] | ||
sysinfo = "0.32.1" | ||
tempfile = "3.8" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
### Test with MCP Inspector | ||
|
||
```bash | ||
npx @modelcontextprotocol/inspector cargo run -p developer | ||
``` | ||
|
||
Then visit the Inspector in the browser window and test the different endpoints. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
use mcp_core::handler::{ResourceError, ToolError}; | ||
use mcp_server::RouterError; | ||
use serde::{Deserialize, Serialize}; | ||
use thiserror::Error; | ||
|
||
#[non_exhaustive] | ||
#[derive(Error, Debug, Clone, Deserialize, Serialize, PartialEq)] | ||
pub enum AgentError { | ||
#[error("Tool not found: {0}")] | ||
ToolNotFound(String), | ||
|
||
#[error("The parameters to the tool call were invalid: {0}")] | ||
InvalidParameters(String), | ||
|
||
#[error("The tool failed during execution with the following output: \n{0}")] | ||
ExecutionError(String), | ||
|
||
#[error("Internal error: {0}")] | ||
Internal(String), | ||
|
||
#[error("Invalid tool name: {0}")] | ||
InvalidToolName(String), | ||
} | ||
|
||
pub type AgentResult<T> = Result<T, AgentError>; | ||
|
||
impl From<AgentError> for ToolError { | ||
fn from(err: AgentError) -> Self { | ||
match err { | ||
AgentError::InvalidParameters(msg) => ToolError::InvalidParameters(msg), | ||
AgentError::InvalidToolName(msg) => ToolError::InvalidParameters(msg), | ||
AgentError::ToolNotFound(msg) => ToolError::NotFound(msg), | ||
AgentError::ExecutionError(msg) => ToolError::ExecutionError(msg), | ||
AgentError::Internal(msg) => ToolError::ExecutionError(msg), | ||
} | ||
} | ||
} | ||
|
||
impl From<AgentError> for ResourceError { | ||
fn from(err: AgentError) -> Self { | ||
match err { | ||
AgentError::InvalidParameters(msg) => ResourceError::NotFound(msg), | ||
_ => ResourceError::NotFound(err.to_string()), | ||
} | ||
} | ||
} | ||
|
||
impl From<AgentError> for RouterError { | ||
fn from(err: AgentError) -> Self { | ||
match err { | ||
AgentError::ToolNotFound(msg) => RouterError::ToolNotFound(msg), | ||
AgentError::InvalidParameters(msg) => RouterError::InvalidParams(msg), | ||
AgentError::ExecutionError(msg) => RouterError::Internal(msg), | ||
AgentError::Internal(msg) => RouterError::Internal(msg), | ||
AgentError::InvalidToolName(msg) => RouterError::ToolNotFound(msg), | ||
} | ||
} | ||
} | ||
|
||
impl From<ResourceError> for AgentError { | ||
fn from(err: ResourceError) -> Self { | ||
match err { | ||
ResourceError::NotFound(msg) => { | ||
AgentError::InvalidParameters(format!("Resource not found: {}", msg)) | ||
} | ||
ResourceError::ExecutionError(msg) => AgentError::ExecutionError(msg), | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use std::path::Path; | ||
|
||
/// Get the markdown language identifier for a file extension | ||
pub fn get_language_identifier(path: &Path) -> &'static str { | ||
match path.extension().and_then(|ext| ext.to_str()) { | ||
Some("rs") => "rust", | ||
Some("py") => "python", | ||
Some("js") => "javascript", | ||
Some("ts") => "typescript", | ||
Some("json") => "json", | ||
Some("toml") => "toml", | ||
Some("yaml") | Some("yml") => "yaml", | ||
Some("sh") => "bash", | ||
Some("go") => "go", | ||
Some("md") => "markdown", | ||
Some("html") => "html", | ||
Some("css") => "css", | ||
Some("sql") => "sql", | ||
Some("java") => "java", | ||
Some("cpp") | Some("cc") | Some("cxx") => "cpp", | ||
Some("c") => "c", | ||
Some("h") | Some("hpp") => "cpp", | ||
Some("rb") => "ruby", | ||
Some("php") => "php", | ||
Some("swift") => "swift", | ||
Some("kt") | Some("kts") => "kotlin", | ||
Some("scala") => "scala", | ||
Some("r") => "r", | ||
Some("m") => "matlab", | ||
Some("pl") => "perl", | ||
Some("dockerfile") => "dockerfile", | ||
_ => "", | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like file this should maybe be part of more central library? but i guess reasonable to wait until we have another (although @michaelneale has a new system that would need these i think)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually after reading, maybe we remove this entirely and only use ToolError from mcp_core