-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.ts
More file actions
33 lines (28 loc) · 772 Bytes
/
server.ts
File metadata and controls
33 lines (28 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { getCountryDataToolConfig } from "./tools/index.js";
import fetchRestCountries from "./api/fetchRestCountries.js";
function createMcpServer() {
const server = new McpServer({
name: "mcp-name",
version: "1.0.0",
capabilities: {
resources: {},
tools: {},
},
});
server.registerTool(
"get_country_data",
getCountryDataToolConfig(),
async ({ countryName }) => {
const res = await fetchRestCountries(countryName);
return {
content: [{ type: "text", text: JSON.stringify(res[0] || []) }],
structuredContent: {
data: res[0] || []
}
};
}
);
return server;
}
export default createMcpServer;