Skip to content

Commit cb58e4b

Browse files
Eugenumber1drewdrewthis
authored andcommitted
Add mcp docs
1 parent 8853c66 commit cb58e4b

File tree

3 files changed

+335
-4
lines changed

3 files changed

+335
-4
lines changed

api-reference/openapiLangWatch.json

+255-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"openapi": "3.1.0",
33
"info": {
44
"title": "LangWatch API",
5-
"version": "1.0.0"
5+
"version": "1.0.0",
6+
"description": "LangWatch openapi spec"
67
},
78
"servers": [
89
{
@@ -796,7 +797,6 @@
796797
}
797798
}
798799
},
799-
800800
"/api/dataset/{slug}/entries": {
801801
"post": {
802802
"responses": {},
@@ -822,6 +822,259 @@
822822
}
823823
}
824824
}
825+
},
826+
"/api/prompts": {
827+
"get": {
828+
"responses": {},
829+
"operationId": "getApiPrompts",
830+
"parameters": [],
831+
"description": "Get all prompts for a project"
832+
},
833+
"post": {
834+
"responses": {},
835+
"operationId": "postApiPrompts",
836+
"parameters": [],
837+
"description": "Create a new prompt",
838+
"requestBody": {
839+
"content": {
840+
"application/json": {
841+
"schema": {
842+
"type": "object",
843+
"properties": {
844+
"name": {
845+
"type": "string",
846+
"minLength": 1
847+
}
848+
},
849+
"required": ["name"]
850+
}
851+
}
852+
}
853+
}
854+
}
855+
},
856+
"/api/prompts/{id}": {
857+
"get": {
858+
"responses": {},
859+
"operationId": "getApiPromptsById",
860+
"parameters": [
861+
{
862+
"schema": {
863+
"type": "string"
864+
},
865+
"in": "path",
866+
"name": "id",
867+
"required": true
868+
}
869+
],
870+
"description": "Get a specific prompt"
871+
},
872+
"put": {
873+
"responses": {},
874+
"operationId": "putApiPromptsById",
875+
"parameters": [
876+
{
877+
"schema": {
878+
"type": "string"
879+
},
880+
"in": "path",
881+
"name": "id",
882+
"required": true
883+
}
884+
],
885+
"description": "Update a prompt",
886+
"requestBody": {
887+
"content": {
888+
"application/json": {
889+
"schema": {
890+
"type": "object",
891+
"properties": {
892+
"name": {
893+
"type": "string",
894+
"minLength": 1
895+
}
896+
}
897+
}
898+
}
899+
}
900+
}
901+
},
902+
"delete": {
903+
"responses": {},
904+
"operationId": "deleteApiPromptsById",
905+
"parameters": [
906+
{
907+
"schema": {
908+
"type": "string"
909+
},
910+
"in": "path",
911+
"name": "id",
912+
"required": true
913+
}
914+
],
915+
"description": "Delete a prompt"
916+
}
917+
},
918+
"/api/prompts/{id}/versions": {
919+
"get": {
920+
"responses": {},
921+
"operationId": "getApiPromptsByIdVersions",
922+
"parameters": [
923+
{
924+
"schema": {
925+
"type": "string"
926+
},
927+
"in": "path",
928+
"name": "id",
929+
"required": true
930+
}
931+
],
932+
"description": "Get all versions for a prompt"
933+
},
934+
"post": {
935+
"responses": {},
936+
"operationId": "postApiPromptsByIdVersions",
937+
"parameters": [
938+
{
939+
"schema": {
940+
"type": "string"
941+
},
942+
"in": "path",
943+
"name": "id",
944+
"required": true
945+
}
946+
],
947+
"description": "Create a new version for a prompt",
948+
"requestBody": {
949+
"content": {
950+
"application/json": {
951+
"schema": {
952+
"type": "object",
953+
"properties": {
954+
"authorId": {
955+
"type": ["string", "null"]
956+
},
957+
"projectId": {
958+
"type": "string",
959+
"minLength": 1
960+
},
961+
"configId": {
962+
"type": "string",
963+
"minLength": 1
964+
},
965+
"schemaVersion": {
966+
"type": "string",
967+
"const": "1.0"
968+
},
969+
"commitMessage": {
970+
"type": "string"
971+
},
972+
"configData": {
973+
"type": "object",
974+
"properties": {
975+
"version": {
976+
"type": "string",
977+
"const": "1.0"
978+
},
979+
"prompt": {
980+
"type": "string",
981+
"minLength": 1
982+
},
983+
"model": {
984+
"type": "string",
985+
"minLength": 1
986+
},
987+
"inputs": {
988+
"type": "array",
989+
"items": {
990+
"type": "object",
991+
"properties": {
992+
"identifier": {
993+
"type": "string",
994+
"minLength": 1
995+
},
996+
"type": {
997+
"type": "string",
998+
"minLength": 1
999+
}
1000+
},
1001+
"required": ["identifier", "type"]
1002+
},
1003+
"minItems": 1
1004+
},
1005+
"outputs": {
1006+
"type": "array",
1007+
"items": {
1008+
"type": "object",
1009+
"properties": {
1010+
"identifier": {
1011+
"type": "string",
1012+
"minLength": 1
1013+
},
1014+
"type": {
1015+
"type": "string",
1016+
"minLength": 1
1017+
}
1018+
},
1019+
"required": ["identifier", "type"]
1020+
},
1021+
"minItems": 1
1022+
},
1023+
"demonstrations": {
1024+
"type": "object",
1025+
"properties": {
1026+
"columns": {
1027+
"type": "array",
1028+
"items": {
1029+
"type": "object",
1030+
"properties": {
1031+
"name": {
1032+
"type": "string",
1033+
"minLength": 1
1034+
},
1035+
"type": {
1036+
"type": "string",
1037+
"minLength": 1
1038+
}
1039+
},
1040+
"required": ["name", "type"]
1041+
}
1042+
},
1043+
"rows": {
1044+
"type": "array",
1045+
"items": {
1046+
"type": "object",
1047+
"additionalProperties": {}
1048+
},
1049+
"default": []
1050+
}
1051+
},
1052+
"required": ["columns"]
1053+
}
1054+
},
1055+
"required": [
1056+
"version",
1057+
"prompt",
1058+
"model",
1059+
"inputs",
1060+
"outputs",
1061+
"demonstrations"
1062+
]
1063+
}
1064+
},
1065+
"required": [
1066+
"authorId",
1067+
"projectId",
1068+
"configId",
1069+
"schemaVersion",
1070+
"commitMessage",
1071+
"configData"
1072+
]
1073+
}
1074+
}
1075+
}
1076+
}
1077+
}
8251078
}
8261079
},
8271080
"components": {
@@ -1102,7 +1355,6 @@
11021355
}
11031356
}
11041357
},
1105-
11061358
"DatasetPostEntries": {
11071359
"type": "object",
11081360
"properties": {

integration/mcp.mdx

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
title: LangWatch MCP Server
3+
sidebarTitle: LangWatch MCP
4+
---
5+
6+
The [LangWatch MCP Server](https://www.npmjs.com/package/@langwatch/mcp-server) is a tool designed to aid finding, searching, and looking up LLM traces from the LangWatch platform via the [Model Context Protocol](https://modelcontextprotocol.io/introduction).
7+
8+
This server facilitates LLM development by allowing the agent to search for traces, understand all the steps in between a problematic output and try to fix the issue.
9+
10+
<iframe
11+
width="720"
12+
height="460"
13+
src="https://www.youtube.com/embed/ZPaG9H-N0uY"
14+
title="YouTube video player"
15+
frameborder="0"
16+
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
17+
allowFullScreen
18+
></iframe>
19+
20+
## Setup in your Codebase
21+
22+
Check out [the integration guides](/integration/overview) to start tracking your agents so both you and Cursor/Windsurf/Claude Code or your favorite coding assistant can debug it.
23+
24+
## Setup in Cursor 👩‍💻
25+
26+
1. Navigate to the Cursor Settings
27+
2. Navigate to the MCP item in the sidebar
28+
3. Set the "name" as "LangWatch"
29+
4. Set the "type" to `command`
30+
5. Set the "command" to `npx -y @langwatch/mcp-server --apiKey=sk-lw-...`
31+
- `--apiKey`: Your LangWatch API key. This is mandatory and must be provided.
32+
- `--endpoint`: *Optional* The endpoint for the LangWatch API. Defaults to `https://app.langwatch.ai` if not specified.
33+
34+
> [!TIP]
35+
> To aid in securing your keys, the MCP will first look at the global system environment variables `LANGWATCH_API_KEY` and `LANGWATCH_ENDPOINT` to check if they have values as well as looking at arguments passed into the server on start.
36+
37+
<img alt="LangWatch MCP Setup" src="https://github.com/langwatch/langwatch/raw/main/assets/mcp-server/cursor-setup.light.webp" width="900" />
38+
39+
## Tools
40+
41+
The MCP Server provides the following tools:
42+
43+
### `get_latest_traces`
44+
45+
- **Description:** Retrieves the latest LLM traces.
46+
- **Parameters:**
47+
- `pageOffset` (optional): The page offset for pagination.
48+
- `daysBackToSearch` (optional): The number of days back to search for traces. Defaults to 1.
49+
50+
### `get_trace_by_id`
51+
52+
- **Description:** Retrieves a specific LLM trace by its ID.
53+
- **Parameters:**
54+
- `id`: The ID of the trace to retrieve.
55+
56+
## Usage in Cursor
57+
58+
To use these tools within Cursor, follow these steps:
59+
60+
1. **Open the Cursor Chat view:**
61+
- `Cmd + I`
62+
63+
2. **Ensure the MCP server is running:**
64+
65+
3. **Interact with your Agent:**
66+
- Ask a question like the following to test the tools are accessible: *Note: When the tool is detected, you'll need to run `Run tool` in the chat view for it to be called.
67+
68+
> "I just ran into an issue while debugging, can you check the latest traces and fix it?"
69+
70+
<img alt="LangWatch MCP Example" src="https://github.com/langwatch/langwatch/raw/main/assets/mcp-server/cursor-example.light.webp" width="900" />
71+
72+
73+
## 🛟 Support
74+
75+
If you have questions or need help, join our community:
76+
77+
- [Discord Community](https://discord.gg/kT4PhDS2gH)
78+
- [Email Support](mailto:support@langwatch.ai)

mint.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@
8787
"integration/rest-api",
8888
"integration/rags-context-tracking",
8989
"concepts",
90-
"integration/cookbooks"
90+
"integration/cookbooks",
91+
"integration/mcp"
9192
]
9293
},
9394
{

0 commit comments

Comments
 (0)